/* ==========================================================================
   Gobi Design Tokens
   --------------------------------------------------------------------------
   THIS FILE IS THE SPEC. Every value here has a destination in the Flutter
   codebase — see design/SPEC.md for the mapping table.

   Rule: no other stylesheet in design/ may contain a literal colour, a raw
   pixel spacing value, or a font-family. If you need one, add it here first.
   That constraint is what makes light and dark a single attribute swap
   ([data-theme]), and what keeps this file and lib/theme/ a mechanical
   transcription of each other.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. THEME-INDEPENDENT TOKENS
   Shared by light and dark. Mirrored by lib/theme/tokens.dart.
   -------------------------------------------------------------------------- */

:root {
  /* ---- Spacing: 4pt base scale -------------------------------------------
     Replaces the current ad-hoc mix (SizedBox 16 x92, 8 x65, 12 x46, 24 x39,
     4 x31, 2, 6, 20 ... and both EdgeInsets.all(16) and .all(16.0)).        */
  --space-0: 0px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* ---- Radius -------------------------------------------------------------
     Four steps, not the current eight (4/6/8/10/12/16/20/24 all in use).     */
  --radius-xs: 6px;   /* badges, tiny chips                                   */
  --radius-sm: 10px;  /* inputs, buttons, small thumbs                        */
  --radius-md: 14px;  /* cards, images, sheets                                */
  --radius-lg: 20px;  /* hero panels, modals, sticky booking card             */
  --radius-full: 999px;

  /* ---- Border width ---- */
  --border-hairline: 1px;
  --border-strong: 2px;   /* focus ring, selected state, status accent bar    */
  --border-indicator: 3px; /* the selected role tab's underline (#260)        */

  /* ---- Hatching: the "can't be booked" pattern (owner calendar) ---- */
  --hatch-stroke: 1.5px;  /* line width                                       */
  --hatch-pitch: 6px;     /* line to line                                     */

  /* ---- Content widths ---------------------------------------------------
     Applied BY DEFAULT. Today ItemerScaffold.constrainContent defaults to
     false, so Home/Browse/ItemDetail run edge-to-edge at 1440px while the
     Rentals dashboard is boxed at 800px. Three widths, one rule each.       */
  --w-page: 1200px;   /* marketplace grids, dashboards                        */
  --w-read: 800px;    /* detail columns, long forms (today's kMaxContentWidth)*/
  --w-narrow: 560px;  /* auth, single-field forms                             */

  /* ---- Layout constants ---- */
  --header-h: 68px;
  --header-h-compact: 56px;
  --gutter: var(--space-6);
  --gutter-compact: var(--space-4);
  --card-min: 260px;      /* browse grid track minimum -> caps at 4 columns   */
  --sidebar-w: 248px;     /* browse filter rail                               */
  --thread-list-w: 340px; /* messages two-pane list column                    */
  --nav-rail-w: 80px;     /* admin NavigationRail at medium (Flutter default) */
  --notif-panel-w: 400px; /* the notification bell's popover (#245)           */
  --notif-panel-h: 560px; /* the popover's tallest, before its list scrolls   */
  --tab-bar-h: 56px;      /* your profile's role tab bar (#260)               */
  --detail-rail-w-md: 320px; /* .detail-layout rail at medium: item, profile  */
  --detail-rail-w: 380px;    /* .detail-layout rail at expanded              */
  --gallery-thumb-w: 72px;   /* item detail gallery thumbnail strip (#371)   */
  --field-h: 44px;        /* input, select and search-field height            */
  --field-h-lg: 52px;     /* .field-lg -- the home hero's search input        */
  --cat-disc: 88px;       /* home category disc, medium and expanded          */
  --cat-disc-compact: 68px; /* home category disc on compact, three across    */
  --result-mark: 64px;    /* .result-mark -- the disc atop a result panel     */
  --result-mark-icon: 32px; /* the icon inside .result-mark                   */

  /* Button sizes. `.btn` itself is 42px with --space-5 padding at --fs-label;
     these are the two variants the landing page needs. Height alone is not
     enough -- padding and type step with it, and a variant that only changed
     height would put those back at the call site as bare numbers.         */
  --btn-h-lg: 50px;       /* .btn-lg -- hero Search                          */
  --btn-h-sm: 34px;       /* .btn-sm -- hero links, "See all", section heads  */

  /* Ceiling on how far fixed-size chrome grows with the user's text scale.
     The browser has no equivalent knob -- this token exists so the Flutter
     side has a documented bound rather than a magic number. 2 is Material's
     accessibility ceiling: a layout must survive 200% text.               */
  --max-chrome-scale: 2;

  /* ---- Motion ---- */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);

  /* ---- Type scale -------------------------------------------------------
     Explicit sizes/weights/leading rather than Material defaults. Names map
     1:1 onto Flutter TextTheme slots (see SPEC.md).                          */
  --fs-display: 44px;   --lh-display: 1.08;  --fw-display: 600;
  --fs-h1: 32px;        --lh-h1: 1.15;       --fw-h1: 600;
  --fs-h2: 24px;        --lh-h2: 1.25;       --fw-h2: 600;
  --fs-h3: 19px;        --lh-h3: 1.3;        --fw-h3: 600;
  --fs-title: 16px;     --lh-title: 1.4;     --fw-title: 600;
  --fs-body-lg: 16px;   --lh-body-lg: 1.55;  --fw-body: 400;
  --fs-body: 14.5px;    --lh-body: 1.55;
  --fs-label: 13px;     --lh-label: 1.35;    --fw-label: 550;
  --fs-caption: 12px;   --lh-caption: 1.35;

  --tracking-tight: -0.02em;  /* display + h1                                 */
  --tracking-normal: 0;
  --tracking-wide: 0.02em;    /* all-caps labels                              */

  /* ---- Elevation ---------------------------------------------------------
     Soft and low. The current design has no elevation hierarchy at all
     because every surface is the same peach.                                 */
  --shadow-0: none;
  --shadow-1: 0 1px 2px rgba(16, 12, 10, 0.04),
              0 1px 3px rgba(16, 12, 10, 0.05);
  --shadow-2: 0 2px 4px rgba(16, 12, 10, 0.04),
              0 6px 16px rgba(16, 12, 10, 0.07);
  --shadow-3: 0 12px 32px rgba(16, 12, 10, 0.13);

  /* ---- Aspect ratios ---- */
  --ratio-card: 4 / 3;    /* item card image — fixed, so rows always align   */
  --ratio-hero: 16 / 10;  /* item detail photo at compact                     */
  --ratio-gallery: 16 / 9; /* item detail main photo at medium+ (#371)         */

  /* ---- Photo overlay ------------------------------------------------------
     Theme-independent on purpose: these sit on top of user photography,
     not on a themed surface, so they must not shift with the palette.        */
  --overlay: rgba(0, 0, 0, 0.55);
  --overlay-soft: rgba(0, 0, 0, 0.28);
  --on-overlay: #ffffff;
}

/* --------------------------------------------------------------------------
   2. PALETTE — LIGHT   (:root, or [data-theme="light"])
   --------------------------------------------------------------------------
   "Warm Neutral": white surfaces, warm-grey ink, and terracotta (#8F4C38) as
   the accent. The accent is for actions and identity — price, primary CTA,
   active nav, focus ring, wordmark — plus, since the "Sunlit" landing page,
   icon chips, step numbers and the hero headline's second line.

   Mirrored by lib/theme/theme_colors.dart (WarmLight),
   lib/theme/semantic_colors.dart (SemanticColors.light) and
   lib/theme/category_tones.dart (CategoryTones.light).
   test/theme/tokens_css_sync_test.dart fails if they drift apart.
   -------------------------------------------------------------------------- */

:root,
:root[data-theme="light"] {
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, sans-serif;
  --font-display-opsz: "opsz" 40, "SOFT" 0, "WONK" 1;

  /* Surfaces: true neutrals with a barely-there warm cast (2% max chroma) */
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #faf9f8;
  --surface-inset: #f4f2f0;   /* price summary blocks, code, map fallback    */
  --surface-scrim: rgba(28, 25, 23, 0.42);

  /* Ink. Measured contrast on --surface: 17.5 : 7.6 : 4.9.
     --ink-subtle is darker than a conventional "muted grey" on purpose: it
     carries placeholder text and metadata. It clears 4.5:1 on --surface (4.9)
     and --surface-sunken (4.6) but NOT on --surface-inset (4.35:1) — a known
     gap, listed in SPEC.md §4 "Contrast". */
  --ink: #1c1917;
  --ink-muted: #57534e;
  --ink-subtle: #78706a;
  --ink-inverse: #ffffff;
  --ink-faint: #a8a29e;    /* decorative strokes and disabled fills ONLY —
                              never text, never an icon carrying meaning     */

  --border: #e7e5e4;
  --border-strong-color: #d6d3d1;

  /* Brand accent */
  --accent: #8f4c38;          /* 6.4:1 on white — AA for body and large      */
  --accent-hover: #7a3f2e;
  --accent-pressed: #653326;
  --accent-soft: #fbede9;     /* selected chip, badge bg, icon chips         */
  --accent-soft-border: #f2ddd6;
  --accent-on: #ffffff;
  --focus-ring: #8f4c38;

  /* Semantic */
  --success: #15703f;   --success-soft: #e7f4ed;   --success-border: #c9e5d6;
  --warning: #a2540a;   --warning-soft: #fdf1e3;   --warning-border: #f5dfc2;
  --danger:  #b3261e;   --danger-soft:  #fdecea;   --danger-border:  #f6d2ce;
  --info:    #1d5c9e;   --info-soft:    #eaf2fb;   --info-border:    #cfe0f3;
  /* Darker than a conventional rating amber: a star is a meaningful non-text
     graphic and needs 3:1 on the surface. #d98f26 measured 2.66:1 and failed;
     this is 3.6:1 on white, 3.4:1 on --surface-sunken. */
  --star:    #be7815;

  /* Landing page ("Sunlit"). An apricot hero and a warm band behind "How
     renting works" — that band only, so every other sunken surface stays
     neutral.
     --accent clears 4.5:1 on both hero stops (the headline's second line). */
  --hero-from: #fdf1e7;
  --hero-to: #f7d9c6;
  --band-warm: #fcf4ee;
  --band-warm-border: #f2ddd6;
  --hero-rule: #e2bda6;        /* lines on the hero ("or", card); 1.3:1+ on both stops */

  /* Category tones — the home page's category discs. Six tones from inside
     the terracotta family, so six categories get six colours without a blue
     or green appearing beside the accent. Each ink clears 4.5:1 on its own
     soft fill. Which category gets which tone lives in
     lib/widgets/home/home_category_tiles.dart. */
  --tone-apricot: #934a1c;   --tone-apricot-soft: #fde3cf;
  --tone-ochre: #73550f;     --tone-ochre-soft: #f6e7c4;
  --tone-rose: #93404f;      --tone-rose-soft: #f8dde0;
  --tone-cinnamon: #7a4628;  --tone-cinnamon-soft: #efdccd;
  --tone-clay: #8f4c38;      --tone-clay-soft: #f6dcd3;
  --tone-sand: #7a5418;      --tone-sand-soft: #f8eedc;

  /* Photo placeholder — must read as "no photo", not as an empty card. */
  --photo-bg: #f1efed;
  --photo-mark: #c9c4bf;
}

/* --------------------------------------------------------------------------
   3. PALETTE — DARK   ([data-theme="dark"])
   --------------------------------------------------------------------------
   Transcribed from the app, where dark was derived rather than designed:
   each ink is lightened until it clears AA on the dark surface #1C1917, and
   each soft/border pair is the same hue pulled down to a low-luminance fill.
   Mirrored by WarmDark, SemanticColors.dark and CategoryTones.dark.
   -------------------------------------------------------------------------- */

:root[data-theme="dark"] {
  --surface: #1c1917;
  --surface-raised: #211e1b;
  --surface-sunken: #171412;
  --surface-inset: #262220;
  --surface-scrim: rgba(0, 0, 0, 0.42);

  --ink: #f5f3f1;
  --ink-muted: #c4bdb7;
  --ink-subtle: #a8a29e;
  --ink-inverse: #1c1917;
  --ink-faint: #78706a;

  --border: #33302d;
  --border-strong-color: #4a4542;

  --accent: #e0866a;
  --accent-hover: #eb9a80;
  --accent-pressed: #c97155;
  --accent-soft: #3a241c;
  --accent-soft-border: #523327;
  --accent-on: #3a1e14;      /* dark ink on the light dark-mode accent       */
  --focus-ring: #e0866a;

  --success: #62c98e;   --success-soft: #12301f;   --success-border: #1e4b31;
  --warning: #e0a155;   --warning-soft: #33230f;   --warning-border: #4d3717;
  --danger:  #f2837b;   --danger-soft:  #3a1a18;   --danger-border:  #572622;
  --info:    #77b0ec;   --info-soft:    #16283a;   --info-border:    #24405c;
  --star:    #e7b45c;

  --hero-from: #2a1f19;
  --hero-to: #3a251b;
  --band-warm: #231c18;
  --band-warm-border: #3a2a22;
  --hero-rule: #5a3c2e;

  --tone-apricot: #f2a774;   --tone-apricot-soft: #4a2d1b;
  --tone-ochre: #ddb45c;     --tone-ochre-soft: #40321a;
  --tone-rose: #ee9aaa;      --tone-rose-soft: #4a2630;
  --tone-cinnamon: #dda47e;  --tone-cinnamon-soft: #432f22;
  --tone-clay: #e8957a;      --tone-clay-soft: #4a2b21;
  --tone-sand: #d9bc8a;      --tone-sand-soft: #3e3220;

  --photo-bg: #26221f;
  --photo-mark: #6b635c;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   4. COMPACT OVERRIDES
   Type steps down below 600px. One place, not per-screen.
   -------------------------------------------------------------------------- */

@media (max-width: 599px) {
  :root {
    --fs-display: 32px;
    --fs-h1: 25px;
    --fs-h2: 20px;
    --fs-h3: 17px;
    --gutter: var(--space-4);
    --header-h: var(--header-h-compact);
  }
}
