/* ==========================================================================
   main.css — global layout, typography, responsive breakpoints
   ==========================================================================
   Design tokens (see also components.css, which shares this :root):
   - Palette is deep indigo + turmeric-yellow + clay red, on a warm
     near-white paper background — a nod to indigo dye and terracotta
     craft traditions from West Bengal, without leaning on a stock
     "cream + terracotta" template.
   - Display face: Fraunces (soft-serif, characterful, used for the
     logo wordmark and headings only).
   - Body/UI face: Inter (neutral workhorse for everything else).
   ========================================================================== */

:root {
  /* Colour */
  --color-bg: #FAF8F4;
  --color-surface: #FFFFFF;
  --color-surface-sunken: #F2EEE5;
  --color-ink: #1C2B39;
  --color-ink-soft: #4B5A68;
  --color-muted: #7A8791;
  --color-border: #E4E0D4;

  --color-primary: #1F3A5F;
  --color-primary-dark: #142639;
  --color-primary-tint: #EAF0F6;

  --color-accent: #E8A33D;
  --color-accent-dark: #C97F1E;

  --color-clay: #B8441E;
  --color-clay-tint: #FBEAE2;

  --color-success: #2F7A4D;
  --color-success-tint: #E8F3EC;
  --color-danger: #B3261E;
  --color-danger-tint: #FBEAEA;

  /* Type */
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Layout */
  --header-height: 64px;
  --bottom-nav-height: 60px;
  --max-width: 1200px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(28, 43, 57, 0.08);
  --shadow-md: 0 6px 20px rgba(28, 43, 57, 0.10);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, p, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--color-ink);
  background: var(--color-bg);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Room for the fixed mobile bottom nav; removed at desktop widths. */
  padding-bottom: var(--bottom-nav-height);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-primary-dark);
  line-height: 1.15;
  font-weight: 600;
}

h1 { font-size: clamp(1.9rem, 1.5rem + 2vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 1.3rem + 1vw, 2rem); }
h3 { font-size: 1.25rem; }

p { color: var(--color-ink-soft); }

/* Visible keyboard focus everywhere */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-accent-dark);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

main { flex: 1; }

/* ---------- Top bar / header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.site-header__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--header-height);
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
  padding-block: var(--space-2);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.site-logo img {
  height: 36px;
  width: auto;
}

.site-logo__text {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  white-space: nowrap;
}

/* ---------- Desktop top nav (hidden on mobile) ---------- */
.site-nav {
  display: none;
  align-items: center;
  gap: var(--space-5);
  flex-shrink: 0;
}

.site-nav a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-ink-soft);
  padding: var(--space-2) 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--color-primary);
  border-color: var(--color-accent);
}

/* ---------- "Policies" nav dropdown ---------- */
.site-nav__dropdown {
  position: relative;
}

.site-nav__dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-ink-soft);
  padding: var(--space-2) 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav__dropdown-caret {
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
}

.site-nav__dropdown:hover .site-nav__dropdown-trigger,
.site-nav__dropdown.is-open .site-nav__dropdown-trigger {
  color: var(--color-primary);
  border-color: var(--color-accent);
}

.site-nav__dropdown.is-open .site-nav__dropdown-caret {
  transform: rotate(180deg);
}

.site-nav__dropdown-panel {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 50;
}

.site-nav__dropdown:hover .site-nav__dropdown-panel,
.site-nav__dropdown.is-open .site-nav__dropdown-panel {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.site-nav__dropdown-panel a {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--color-ink-soft);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.site-nav__dropdown-panel a:hover,
.site-nav__dropdown-panel a:focus-visible {
  background: var(--color-surface-sunken);
  color: var(--color-primary);
}

.header-cart {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  position: relative;
  flex-shrink: 0;
  padding: var(--space-2);
  color: var(--color-primary-dark);
}

.header-cart svg {
  width: 22px;
  height: 22px;
}

.header-cart__badge {
  position: absolute;
  top: -2px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-clay);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ---------- Mobile bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--bottom-nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.68rem;
  color: var(--color-muted);
  position: relative;
}

.bottom-nav a svg {
  width: 22px;
  height: 22px;
}

.bottom-nav a.is-active {
  color: var(--color-primary);
}

.bottom-nav a.is-active svg {
  stroke: var(--color-primary);
}

.bottom-nav__badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 22px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-clay);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ---------- Account "in development" modal (mobile bottom nav) ---------- */
.account-dev-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

/* IMPORTANT: without this, the modal never actually hides. The `hidden`
   HTML attribute relies on the browser's default `[hidden]{display:none}`
   rule, which has the exact same specificity (0,1,0) as `.account-dev-modal`
   above — and author CSS wins specificity ties over the UA stylesheet, so
   `display:flex` was winning and showing the modal on every page load
   regardless of the `hidden` attribute. This selector has higher
   specificity (0,2,0), so it correctly wins instead. */
.account-dev-modal[hidden] {
  display: none;
}

.account-dev-modal__card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-6) var(--space-5);
  max-width: 320px;
  text-align: center;
}

.account-dev-modal__card p {
  margin-bottom: var(--space-4);
  color: var(--color-ink);
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--color-primary-dark);
  color: #DDE6EE;
  margin-top: var(--space-8);
}

.site-footer__inner {
  max-width: var(--max-width);
  margin-inline: auto;
  padding: var(--space-7) var(--space-4);
  display: grid;
  gap: var(--space-6);
  grid-template-columns: 1fr;
}

.site-footer h4 {
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.site-footer ul { display: flex; flex-direction: column; gap: var(--space-2); }

.site-footer a {
  color: #C3D2DE;
  font-size: 0.92rem;
}

.site-footer a:hover { color: var(--color-accent); }

.site-footer__bottom {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding: var(--space-4);
  text-align: center;
  font-size: 0.8rem;
  color: #93A6B5;
}

/* ---------- Page header (About/Terms/Category/etc.) ---------- */
.page-header {
  padding: var(--space-7) 0 var(--space-5);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-6);
}

.page-header p { max-width: 60ch; margin-top: var(--space-2); }

.breadcrumb {
  font-size: 0.82rem;
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}

.breadcrumb a { color: var(--color-primary); }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------- Static content pages (About / Terms) ---------- */
.prose { max-width: 68ch; overflow-wrap: break-word; word-break: break-word; }
.prose h1 { margin-top: var(--space-6); margin-bottom: var(--space-2); }
.prose h2 { margin-top: var(--space-6); margin-bottom: var(--space-2); }
.prose h2:first-child, .prose h1:first-child { margin-top: 0; }
.prose h3 { margin-top: var(--space-5); margin-bottom: var(--space-2); }
.prose h4, .prose h5, .prose h6 { margin-top: var(--space-4); margin-bottom: var(--space-2); }
.prose h4 { font-size: 1.05rem; }
.prose h5 { font-size: 0.95rem; font-weight: 600; }
.prose h6 { font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.prose p { margin-bottom: var(--space-3); }
.prose ul, .prose ol { list-style: disc; padding-left: 1.4em; margin-bottom: var(--space-3); }
.prose ol { list-style: decimal; }
.prose li { margin-bottom: var(--space-1); color: var(--color-ink-soft); }
.prose::after { content: ""; display: table; clear: both; }
.prose blockquote { margin: var(--space-4) 0; padding: var(--space-2) var(--space-4); border-left: 3px solid var(--color-accent); color: var(--color-ink-soft); font-style: italic; }
.prose figure { margin: var(--space-4) 0; }
.prose figure img { max-width: 100%; border-radius: var(--radius-md); display: block; }
.prose figure figcaption { font-size: 0.85rem; color: var(--color-ink-soft); text-align: center; margin-top: var(--space-1); }
.prose img { border-radius: var(--radius-md); }
.prose a { color: var(--color-accent-dark); }

/* ---------- Empty / error states ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-muted);
}

.empty-state h2 { color: var(--color-primary-dark); margin-bottom: var(--space-2); }

/* ---------- 404 page ---------- */
.notfound {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

.notfound__code {
  font-family: var(--font-display);
  font-size: clamp(4rem, 3rem + 6vw, 7rem);
  color: var(--color-accent);
  line-height: 1;
}

/* ==========================================================================
   Responsive breakpoints
   ========================================================================== */

/* Mobile: 2-row header — row 1 is brand name only, row 2 is a full-width
   search bar. The header cart icon is hidden here because the bottom nav
   (mobile only) already has a Cart tab with its own live badge — showing
   the count in two places at once on a small screen was redundant. */
@media (max-width: 767px) {
  .header-cart { display: none; }
  .site-header__bar .search-wrap {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
    margin-top: 2px;
  }
}

/* Tablet and up: reveal desktop nav, hide bottom nav */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .site-nav { display: flex; }
  .site-footer__inner { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .site-footer__inner { grid-template-columns: 2fr 1fr 1fr; }
}
