/* ==========================================================================
   BINDI WHOLESALE — FOUNDATION
   Tokens, reset, typography, focus, motion, primitives.
   Screen-level layout and the app chrome live in portal.css.
   ========================================================================== */

:root {
  /* ---------------------------------------------------------- palette --- */
  --color-forest: #0a2f17;
  --color-forest-dark: #061e0e;
  --color-forest-surface: #0f3d20;
  --color-forest-tint: rgba(10, 47, 23, 0.08);

  --color-cream: #faf5e6;
  --color-cream-warm: #f4edd8;
  --color-cream-surface: #f7f1df;
  --color-cream-muted: #eae3cd;

  --color-gold: #eebc4a;
  --color-gold-hover: #f7c95e;
  --color-gold-glow: rgba(238, 188, 74, 0.35);

  /* #b28a3c measured 3.18:1 on white and failed AA. Still only safe for
     small text on white — on cream it lands at 4.16, so use --color-muted-gold-deep
     for small copy over a cream surface. */
  --color-muted-gold: #927131;
  --color-muted-gold-deep: #7a5f28;
  --color-muted-gold-tint: rgba(146, 113, 49, 0.14);

  --color-mint: #e8f3ec;
  --color-mint-dark: #cfe5d6;
  /* #008a5e measured 4.38:1 on white. This one clears AA on white; text sitting
     on a mint surface needs --color-mint-ink instead (4.05 vs 5.92). */
  --color-mint-accent: #00865b;
  --color-mint-ink: #00694a;

  --color-danger: #b3261e;
  --color-danger-soft: #fdecea;
  --color-danger-border: rgba(179, 38, 30, 0.28);

  --color-white: #ffffff;
  --color-charcoal: #14241a;
  --color-charcoal-muted: #4e6054;
  --color-border-light: rgba(10, 47, 23, 0.1);
  --color-border-strong: rgba(10, 47, 23, 0.18);
  --color-border-gold: rgba(238, 188, 74, 0.35);

  /* Focus ring. Overridden to gold inside dark chrome. */
  --color-focus: #0a2f17;

  /* ------------------------------------------------------- typography --- */
  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* ---------------------------------------------------------- geometry --- */
  --radius-outer: 2.5rem;
  --radius-inner: calc(2.5rem - 8px);
  --radius-card: 1.75rem;
  --radius-card-inner: calc(1.75rem - 6px);
  --radius-nested: 1.25rem;
  --radius-pill: 9999px;
  --radius-sm: 0.75rem;

  /* --------------------------------------------------------- elevation --- */
  --shadow-portal: 0 40px 80px -20px rgba(10, 47, 23, 0.12), 0 20px 40px -15px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 16px 36px -10px rgba(10, 47, 23, 0.08);
  --shadow-gold-cta: 0 12px 32px -6px rgba(238, 188, 74, 0.45);
  --shadow-drawer: -20px 0 60px rgba(6, 30, 14, 0.35);
  --inset-specular-light: inset 0 1px 1px rgba(255, 255, 255, 0.35);
  --inset-specular-dark: inset 0 1px 1px rgba(255, 255, 255, 0.12);

  /* ------------------------------------------------------------ motion --- */
  --ease-elastic: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snappy: cubic-bezier(0.32, 0.72, 0, 1);

  /* ------------------------------------------------------------ metrics --- */
  --header-h: 60px;
  --bottom-nav-h: 62px;
  --cart-bar-h: 60px;
  --tap: 44px;                       /* smallest touch target we ship */
  --gutter: 16px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

@media (min-width: 768px) {
  :root {
    --header-h: 66px;
    --gutter: 24px;
  }
}

/* ==========================================================================
   RESET
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  background: var(--color-cream);
  color: var(--color-charcoal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  /* clip, not hidden: `overflow-x: hidden` turns this into a scroll container
     and kills position:sticky on the header. */
  overflow-x: clip;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  background: var(--color-cream);
  color: var(--color-charcoal);
  min-height: 100dvh;
  overflow-x: clip;
  position: relative;
}

img, video { max-width: 100%; height: auto; }
svg { max-width: 100%; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
}

button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

ul, ol { list-style: none; }

a { color: var(--color-forest); text-decoration-thickness: 1px; text-underline-offset: 3px; }

hr { border: 0; border-top: 1px solid var(--color-border-light); }

/* Every interactive control clears the 44px touch floor. */
button, [role="button"], summary, select {
  min-height: var(--tap);
}

/* ==========================================================================
   TYPOGRAPHY
   Display faces set their own leading — body's 1.6 is far too loose for
   Fraunces at display sizes.
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -0.015em;
  color: var(--color-forest);
  text-wrap: balance;
}

h1 { font-size: clamp(1.75rem, 5.2vw, 2.75rem); line-height: 1.05; }
h2 { font-size: clamp(1.35rem, 3.4vw, 1.85rem); line-height: 1.1; }
h3 { font-size: clamp(1.1rem, 2.6vw, 1.35rem); }
h4, h5, h6 { font-size: 1rem; line-height: 1.25; }

.display-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: var(--color-forest);
  text-wrap: balance;
}

.display-title em { font-style: italic; color: var(--color-muted-gold-deep); }

.eyebrow {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  line-height: 1.3;
  color: var(--color-charcoal-muted);
}

.lede { font-size: 1rem; color: var(--color-charcoal-muted); max-width: 62ch; }
.muted { color: var(--color-charcoal-muted); }
.small { font-size: 12px; line-height: 1.5; }

/* Money and order codes: monospace, tabular, and never broken from their unit. */
.money, .order-code, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.money--lg { font-size: 1.25rem; font-weight: 800; }
.money--strike { text-decoration: line-through; font-weight: 500; color: var(--color-charcoal-muted); }

.order-code {
  font-size: 13px;
  font-weight: 800;
  color: var(--color-forest);
  background: var(--color-cream);
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  display: inline-block;
}

/* ==========================================================================
   FOCUS
   The old build suppressed outlines on inputs and never restored them.
   ========================================================================== */

:focus { outline: none; }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Dark chrome flips the ring to gold so it stays visible on forest. */
.on-forest, .on-forest :focus-visible { --color-focus: var(--color-gold); }

.skip-link {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 50%;
  z-index: 5000;
  transform: translate(-50%, calc(-100% - 24px));
  background: var(--color-gold);
  color: var(--color-forest-dark);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  padding: 12px 22px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-gold-cta);
  transition: transform 0.2s var(--ease-snappy);
}

.skip-link:focus { transform: translate(-50%, 0); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   MOTION
   ========================================================================== */

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

/* ==========================================================================
   PAPER GRAIN
   ========================================================================== */

.grain-source { position: absolute; width: 0; height: 0; overflow: hidden; }

.paper-grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
  opacity: 0.042;
  filter: url(#paper-grain-filter);
  background: #ffffff;
}

/* ==========================================================================
   SURFACES — double-bezel (Doppelrand) wrappers
   ========================================================================== */

.doppel-shell {
  background: rgba(10, 47, 23, 0.03);
  border: 1px solid rgba(10, 47, 23, 0.09);
  border-radius: var(--radius-outer);
  padding: 8px;
  box-shadow: var(--shadow-card);
}

.doppel-shell-dark {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-outer);
  padding: 8px;
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.4);
}

.doppel-core {
  border-radius: var(--radius-inner);
  background: var(--color-white);
  padding: clamp(20px, 4vw, 32px);
  position: relative;
  overflow: hidden;
  height: 100%;
}

.doppel-core-forest {
  border-radius: var(--radius-inner);
  background: var(--color-forest);
  color: var(--color-cream);
  padding: clamp(22px, 4vw, 36px);
  position: relative;
  overflow: hidden;
  height: 100%;
  box-shadow: var(--inset-specular-dark);
  --color-focus: var(--color-gold);
}

.doppel-core-forest h1,
.doppel-core-forest h2,
.doppel-core-forest h3 { color: var(--color-white); }

.doppel-core-mint {
  border-radius: var(--radius-inner);
  background: var(--color-mint);
  color: var(--color-forest);
  padding: clamp(20px, 4vw, 32px);
  position: relative;
  overflow: hidden;
  height: 100%;
}

.card {
  background: var(--color-white);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-card);
  padding: clamp(18px, 3.5vw, 26px);
  box-shadow: var(--shadow-card);
}

.panel {
  background: var(--color-cream-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-nested);
  padding: clamp(16px, 3vw, 22px);
}

/* ==========================================================================
   LAYOUT UTILITIES
   ========================================================================== */

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack--sm { gap: 8px; }
.stack--lg { gap: 24px; }

.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.cluster--between { justify-content: space-between; }

.row-between {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.divider { height: 1px; background: var(--color-border-light); border: 0; }
.nowrap { white-space: nowrap; }
.min-w-0 { min-width: 0; }

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn-gold-cta,
.btn-forest-cta {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 8px 6px 22px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  min-height: 48px;
  user-select: none;
  transition: transform 0.25s var(--ease-elastic), background-color 0.2s ease, box-shadow 0.25s ease;
}

.btn-gold-cta {
  background: var(--color-gold);
  color: var(--color-forest-dark);
  border: 1px solid transparent;
  box-shadow: var(--shadow-gold-cta);
}

.btn-forest-cta {
  background: var(--color-forest);
  color: var(--color-cream);
  border: 1px solid var(--color-border-gold);
  --color-focus: var(--color-gold);
}

.btn-icon-bubble {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(10, 47, 23, 0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-forest-dark);
  flex-shrink: 0;
  transition: transform 0.25s var(--ease-elastic), background-color 0.2s ease;
}

.btn-forest-cta .btn-icon-bubble {
  background: rgba(238, 188, 74, 0.18);
  color: var(--color-gold);
}

@media (hover: hover) {
  .btn-gold-cta:hover:not(:disabled) {
    background: var(--color-gold-hover);
    box-shadow: 0 16px 40px -6px rgba(238, 188, 74, 0.5);
    transform: translateY(-1px);
  }
  .btn-forest-cta:hover:not(:disabled) {
    background: var(--color-forest-surface);
    color: var(--color-gold);
    transform: translateY(-1px);
  }
  .btn-gold-cta:hover:not(:disabled) .btn-icon-bubble,
  .btn-forest-cta:hover:not(:disabled) .btn-icon-bubble { transform: translateX(2px); }
  .btn-forest-cta:hover:not(:disabled) .btn-icon-bubble { background: var(--color-gold); color: var(--color-forest); }
}

.btn-gold-cta:active:not(:disabled),
.btn-forest-cta:active:not(:disabled) { transform: scale(0.985); }

.btn-secondary-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: transparent;
  color: var(--color-forest);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-border-strong);
  text-decoration: none;
  min-height: var(--tap);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

@media (hover: hover) {
  .btn-secondary-outline:hover:not(:disabled) {
    border-color: var(--color-forest);
    background: rgba(10, 47, 23, 0.05);
  }
}

.btn-quiet {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-forest);
  background: transparent;
}

@media (hover: hover) {
  .btn-quiet:hover { background: rgba(10, 47, 23, 0.06); }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  color: var(--color-forest);
  background: transparent;
  flex-shrink: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}

@media (hover: hover) {
  .icon-btn:hover { background: rgba(10, 47, 23, 0.08); }
}

/* One disabled treatment everywhere: flat, grey, obviously inert. */
.btn-gold-cta:disabled,
.btn-forest-cta:disabled,
.btn-secondary-outline:disabled,
.btn-quiet:disabled,
.icon-btn:disabled {
  background: var(--color-cream-muted);
  color: var(--color-charcoal-muted);
  border-color: transparent;
  box-shadow: none;
  transform: none;
  opacity: 0.85;
}

.btn-gold-cta:disabled .btn-icon-bubble,
.btn-forest-cta:disabled .btn-icon-bubble {
  background: rgba(10, 47, 23, 0.08);
  color: var(--color-charcoal-muted);
}

/* ==========================================================================
   BADGES & CHIPS
   ========================================================================== */

.badge-gold, .badge-mint, .badge-forest, .badge-neutral, .badge-danger {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.5;
}

.badge-gold { background: var(--color-gold); color: var(--color-forest-dark); }
.badge-mint { background: var(--color-mint); color: var(--color-mint-ink); }
.badge-forest { background: var(--color-forest); color: var(--color-gold); }
.badge-neutral { background: var(--color-cream-muted); color: var(--color-charcoal); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }

/* ==========================================================================
   FORMS
   ========================================================================== */

.form-field { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-charcoal-muted);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--color-white);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: 16px;              /* 16px stops iOS zooming the field on focus */
  line-height: 1.4;
  color: var(--color-charcoal);
  min-height: var(--tap);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-textarea { min-height: 120px; resize: vertical; }

.form-select {
  appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-charcoal-muted) 50%),
                    linear-gradient(135deg, var(--color-charcoal-muted) 50%, transparent 50%);
  background-position: right 18px center, right 13px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-forest);
  box-shadow: 0 0 0 3px rgba(10, 47, 23, 0.1);
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--color-charcoal-muted); opacity: 0.75; }

.form-input[aria-invalid="true"],
.form-select[aria-invalid="true"],
.form-textarea[aria-invalid="true"] { border-color: var(--color-danger); }

.form-hint { font-size: 12px; color: var(--color-charcoal-muted); }
.form-error { font-size: 12px; font-weight: 700; color: var(--color-danger); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 700px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid > .form-field--wide { grid-column: 1 / -1; }
}

/* ==========================================================================
   ASYNC STATES — loading / empty / error
   Every API-backed view renders one of these; none of them rely on motion
   alone to say what is happening.
   ========================================================================== */

.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 36px 20px;
  border-radius: var(--radius-nested);
  background: var(--color-white);
  border: 1px solid var(--color-border-light);
  color: var(--color-charcoal-muted);
}

.state-block__title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--color-forest);
}

.state-block__text { font-size: 14px; max-width: 46ch; }
.state-block--error { background: var(--color-danger-soft); border-color: var(--color-danger-border); color: var(--color-danger); }
.state-block--error .state-block__title { color: var(--color-danger); }
.state-block__icon { color: currentColor; opacity: 0.75; }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid rgba(10, 47, 23, 0.15);
  border-top-color: var(--color-forest);
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--color-cream-muted);
  border-radius: var(--radius-sm);
  min-height: 14px;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer { to { transform: translateX(100%); } }

.skeleton--line { height: 12px; }
.skeleton--title { height: 18px; width: 60%; }
.skeleton--pill { height: 28px; width: 90px; border-radius: var(--radius-pill); }
