
/*
  styles.css

  This file contains the core styles for the Campus Shop e-commerce site.
  It uses a mobile-first approach and CSS variables for easy theming and maintenance.

  - :root: Defines light and dark theme color variables.
  - Base Styles: Sets global styles for typography, layout, and form elements.
  - Components: Contains styles for reusable UI components like buttons, cards, and modals.
  - Sections: Styles for major layout areas like the header, footer, and product grid.
  - Accessibility: Includes focus-visible states and other accessibility improvements.
  - Media Queries: Adjusts layout and styles for different screen sizes.
*/

/* 
  Color and Theme Variables 
  - Defines colors for light (default) and dark themes.
  - Uses a `data-theme` attribute on the <html> element to switch between themes.
*/
:root {
  --bg: #F8F5F2;
  --panel: #FFFFFF;
  --text: #312E2B;
  --muted: #6E665C;
  --brand: #45736C;
  --brand-light: rgba(69, 115, 108, 0.12);
  --border: #E2DED7;
  --brand-accent: #5A9188;
  --success: #8FA68E;
  --error: #BF6D5A;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.07);
  --shadow-md: 0 8px 32px rgba(69, 115, 108, 0.12);
  --font-body: 'Inter', 'Segoe UI', Arial, sans-serif;
}

:root[data-theme='dark'] {
  --bg: #23201D;
  --panel: #2C2824;
  --text: #E6E1DA;
  --muted: #BFBCB4;
  --brand: #76A09E;
  --brand-light: rgba(118, 160, 158, 0.15);
  --border: #37332E;
  --brand-accent: #8ABAB6;
  --success: #A5C6AB;
  --error: #D69781;
}

/* Base & Typography */
html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
p,
ul,
li {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--text);
}

/* Layout */
.container {
  width: min(100% - 2rem, 1100px);
  margin: 0 auto;
}

/* 
  Header & Navigation
  - Uses Flexbox for alignment.
  - Includes a mobile-first "hamburger" menu.
*/
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  font-weight: 700;
  font-size: 1.5rem;
}

.logo-img {
  height: 48px;
  width: 48px;
}

.menu-toggle {
  display: none;
  /* Hidden by default, shown on mobile */
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 1001;
  color: var(--text);
}

.menu-toggle .icon-menu {
  display: block;
}

.menu-toggle .icon-close {
  display: none;
}

.menu-toggle.is-open .icon-menu {
  display: none;
}

.menu-toggle.is-open .icon-close {
  display: block;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  color: var(--muted);
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.nav-link.active,
.nav-link:hover {
  color: var(--brand);
  background: var(--brand-light);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* 
  Action Buttons (Circle Buttons) 
  - Used for search, cart, theme, and coupon actions.
*/
.circle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  color: var(--brand);
}

.circle-btn:hover {
  background: var(--brand);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.circle-btn img {
  width: 1.25rem;
  height: 1.25rem;
}

.cart-btn {
  overflow: visible;
}

.cart-count {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--brand);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 2px;
}

.theme-btn .theme-icon-light {
  display: none;
}

html[data-theme='dark'] .theme-btn .theme-icon-light {
  display: block;
}

html[data-theme='dark'] .theme-btn .theme-icon-dark {
  display: none;
}

/* Search Component */
.search-container {
  display: flex;
  align-items: center;
  position: relative;
}

.search-toggle {
  z-index: 2;
}

.search-input {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  height: 44px;
  width: 44px;
  padding-left: 40px;
  padding-right: 16px;
  font-size: 1rem;
  color: var(--text);
  position: absolute;
  right: 0;
  transition: width 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  z-index: 1;
}

.search-input:focus {
  outline: 2px solid var(--brand);
}

.search-container.active .search-input {
  width: 250px;
  opacity: 1;
}

/* Main Content & Sections */
.story {
  text-align: center;
  max-width: 600px;
  margin: 0 auto 3rem;
}

.story h1 {
  font-size: clamp(2.2rem, 5vw, 3rem);
  line-height: 1.1;
  margin-bottom: 1rem;
}

.story p {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 2rem;
}

.search-status {
  margin-top: 1rem;
  font-style: italic;
  color: var(--muted);
  min-height: 1.2em;
}

#recent {
  margin-top: 3rem;
}

#recent h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  text-align: center;
}

/* Product Card */
.product-card {
  background: var(--panel);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.25s ease;
  text-decoration: none;
  color: var(--text);
}

.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
  border-color: var(--brand);
}

.product-card-img-wrapper {
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.product-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.product-card:hover .product-card-img {
  transform: scale(1.05);
}

.product-card-info {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  text-align: center;
}

.product-card-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.product-card-price {
  color: var(--brand);
  font-weight: 600;
  margin-top: auto;
}

/* Support Section */
.support-section {
  margin-top: 4rem;
  background: var(--panel);
  border-radius: 20px;
  padding: 2.5rem;
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  border: 1px solid var(--border);
}

.support-section h2 {
  margin-bottom: 1rem;
  font-size: 1.8rem;
}

.support-section p {
  line-height: 1.6;
  color: var(--muted);
}

.support-faq {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.75rem;
}

.support-faq li {
  background: var(--bg);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  line-height: 1.5;
  border: 1px solid var(--border);
}

/* Contact Form */
.contact-card {
  background: var(--bg);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.contact-card--alt {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  color: #FFFFFF;
  border: none;
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 1rem;
}

.contact-card--alt::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.contact-card--alt > * {
  position: relative;
  z-index: 1;
}

.contact-card__lead {
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.6;
}

.contact-card-list {
  display: grid;
  gap: 0.6rem;
  padding-top: 0.25rem;
}

.contact-card-list li {
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.5;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.5rem;
}

.contact-card-list li::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-top: 0.45rem;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.contact-card__cta {
  justify-self: start;
}


.contact-card--alt .btn {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: none;
}

.contact-card--alt .btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: none;
}

.contact-card h3 {
  margin-bottom: 1rem;
}

#contact-form {
  display: grid;
  gap: 1rem;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

input,
textarea {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s;
  width: 100%;
  box-sizing: border-box;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-light);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.btn {
  background: var(--brand);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  text-align: center;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.form-status {
  font-weight: 600;
  margin-top: 0.5rem;
  min-height: 1.5em;
}

.form-status.success {
  color: var(--success);
}

.form-status.error {
  color: var(--error);
}

/* Footer */
.footer {
  margin-top: 3rem;
  padding: 2rem 0;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.footer-link {
  color: var(--muted);
  font-weight: 600;
}

.footer-link:hover {
  color: var(--brand);
}

/*
  Toast Notifications
  - Appears at the bottom of the screen.
*/
#toast-container {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.toast {
  background: var(--panel);
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(20px);
  animation: toast-in 0.3s forwards;
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 
  Mini-Cart Sidebar 
  - Slides in from the right.
  - Includes an overlay to cover the main content.
*/
.mini-cart {
  position: fixed;
  inset: 0;
  z-index: 1000;
  visibility: hidden;
}

.mini-cart.is-open {
  visibility: visible;
}

.mini-cart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.3s;
}

.mini-cart.is-open .mini-cart-overlay {
  opacity: 1;
}

.mini-cart-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(380px, 90vw);
  background: var(--panel);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.mini-cart.is-open .mini-cart-panel {
  transform: translateX(0);
}

.mini-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mini-cart-header h2 {
  font-size: 1.4rem;
}

.mini-cart-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
}

.mini-cart-close:hover {
  color: var(--text);
}

.mini-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: grid;
  gap: 1.25rem;
  align-content: start;
}

.mini-cart-item {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.mini-cart-item img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}

.mini-cart-item-info {
  flex-grow: 1;
}

.mini-cart-item-name {
  font-weight: 600;
}

.mini-cart-item-price {
  color: var(--muted);
  font-size: 0.9rem;
}

.mini-cart-item-remove {
  font-size: 0.8rem;
  color: var(--error);
  cursor: pointer;
  text-decoration: underline;
}

.mini-cart-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 0;
}

.mini-cart-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 1rem;
  flex-shrink: 0;
}

.mini-cart-summary {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.1rem;
}

/*
  Modal Dialogs
  - Used for coupon and quick view.
  - Centered on the screen with an overlay.
*/
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 2rem;
  width: min(100%, 500px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  position: relative;
}

.modal-overlay.is-open .modal-panel {
  transform: scale(1);
  opacity: 1;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

/* Coupon Modal Specifics */
#coupon-modal h2 {
  text-align: center;
  margin-bottom: 0.5rem;
}

#coupon-modal p {
  text-align: center;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.scratch-card-container {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
}

#scratch-canvas {
  position: absolute;
  inset: 0;
  cursor: grab;
}

.scratch-card-container canvas {
  width: 100%;
  height: 100%;
}

.scratch-card-container.is-revealed #scratch-canvas {
  display: none;
}

.scratch-card-container.is-revealed .coupon-code {
  box-shadow: inset 0 0 0 2px var(--brand);
}

.coupon-code {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--brand);
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 12px;
}

.coupon-message {
  text-align: center;
  font-weight: 600;
  color: var(--brand);
  min-height: 1.5rem;
  margin-top: 1rem;
}

.coupon-note {
  text-align: center;
  color: var(--muted);
  margin-top: 0.75rem;
}

/* Accessibility */
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.circle-btn:focus-visible,
.btn:focus-visible {
  outline-color: var(--brand);
}

.nav-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* 
  Media Queries (Mobile-first) 
  - Adjustments for tablet and desktop screens.
*/

/* Tablet and larger */
@media (min-width: 769px) {
  .menu-toggle {
    display: none;
  }

  .main-nav {
    display: flex !important;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .header {
    flex-wrap: wrap;
    position: relative;
  }

  .menu-toggle {
    display: block;
  }

  .main-nav {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
    background: var(--panel);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 1rem;
    border-top: 1px solid var(--border);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
  }

  .main-nav.is-open {
    display: flex;
  }

  .nav-links {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  .nav-link {
    width: 100%;
  }

  .nav-actions {
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    justify-content: space-around;
  }

  .support-section {
    grid-template-columns: 1fr;
    padding: 1.5rem;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .logo-text {
    display: none;
    /* Hide text on very small screens to save space */
  }

  .search-container.active .search-input {
    width: 180px;
  }
}
