/* ==========================================================================
   OUR SPACE: design tokens
   Ivory paper, espresso ink and one deep wax burgundy. Every colour, size,
   radius, shadow and timing in the app comes from here, so a change in
   this file changes the whole app consistently.

   The accent comes in two roles:
   --wax        fills: buttons, your bubbles, checked boxes (white text on top)
   --wax-text   text, icons, focus rings and thin lines on the page
   In light mode they are the same colour. In dark mode they differ, because
   no single red reads well both under white text and on espresso.
   ========================================================================== */

/* Phones with a Dynamic Island report a top inset of 59px or more (notched
   ones, like the iPhone 13, 50px or less). iOS also softens what sits just
   under the island, so those phones alone get a little extra headroom. */
:root { --island-room: clamp(0px, (env(safe-area-inset-top, 0px) - 50px) * 100, 18px); }

:root {
  color-scheme: light;

  /* Surfaces */
  --paper: #faf6f0;           /* app background */
  --paper-deep: #f2eae0;      /* grouped areas, inputs, segmented controls */
  --card: #fffdfa;            /* raised surfaces */
  --polaroid: #fffdf8;
  --tape: rgba(232, 214, 168, 0.72);

  /* Ink (contrast on --paper: 15:1, 6.1:1, 4.5:1) */
  --ink: #2b1e1a;
  --ink-soft: #6b5a52;
  --ink-faint: #806e63;
  --rule: #ece3d8;
  --rule-strong: #dcd0c2;
  --hairline: rgba(60, 35, 25, 0.12);

  /* Accent: wax burgundy (7.7:1 on paper, white on it 8.3:1) */
  --wax: #8e2a2e;
  --wax-deep: #6f1d22;
  --wax-text: #8e2a2e;
  --wax-tint: rgba(142, 42, 46, 0.08);
  --on-wax: #ffffff;
  --blush: #f3e3df;           /* soft tint behind accent icons */

  /* Supporting colours, used sparingly and only for meaning */
  --blue: #2f4a6b;            /* second person's ink */
  --sage: #6e8b6a;            /* online, success */
  --danger: #b3261e;

  /* Chat */
  --bubble-mine: var(--wax);
  --on-bubble-mine: #ffffff;
  --bubble-theirs: #ece6e0;   /* flat warm grey; ink 13:1, secondary ink 5.3:1 */
  --tick-read: #a9dcff;

  /* Elevation */
  --shadow-paper: 0 1px 2px rgba(60, 35, 20, 0.05), 0 6px 18px -6px rgba(60, 35, 20, 0.12);
  --shadow-lift: 0 2px 6px rgba(60, 35, 20, 0.06), 0 16px 32px -10px rgba(60, 35, 20, 0.2);
  --shadow-float: 0 10px 24px -8px rgba(110, 25, 30, 0.45);
  --shadow-sheet: 0 -10px 40px rgba(34, 26, 21, 0.18);

  /* Radius */
  --r-xs: 8px;                /* chips, tags */
  --r-sm: 14px;               /* inputs, tiles */
  --r-md: 20px;               /* cards, photos */
  --r-lg: 26px;               /* feature cards */
  --r-bubble: 22px;
  --r-sheet: 28px;
  --r-full: 999px;

  /* Spacing: a 4pt grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;

  /* Type */
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  /* San Francisco on iPhone and Mac; Inter (its closest open cousin) elsewhere. */
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  /* Small labels and times use the same font with even-width numbers. */
  --mono: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --hand: "Homemade Apple", "Bradley Hand", cursive;   /* signatures */
  --marker: var(--hand);   /* the old caption font, retired in Phase 4; kept as an alias */

  --text-display: 5.5rem;     /* 88: the day counter */
  --text-large: 2.625rem;     /* 42: page titles (serif) */
  --text-title: 1.625rem;     /* 26: section titles (serif) */
  --text-headline: 1.0625rem; /* 17: row titles (sans, 600) */
  --text-body: 1rem;          /* 16: body, inputs (never smaller, or iOS zooms) */
  --text-callout: 0.9375rem;  /* 15 */
  --text-foot: 0.8125rem;     /* 13: secondary lines */
  --text-cap: 0.6875rem;      /* 11: uppercase labels, +0.1em tracking */

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);   /* the iOS sheet curve */
  --fast: 160ms;
  --med: 360ms;
  --press: 120ms;
  --sheet: 420ms;
  --page: 220ms;                                  /* tab to tab: quick */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  /* Layout */
  --nav-height: 74px;         /* room the floating tab bar takes; the home indicator inset is added on top */
  --gutter: 1.25rem;
  --tap: 44px;                /* minimum touch target */
  --grain-opacity: 0.1;
  --glass: rgba(250, 246, 240, 0.86);
  /* Liquid Glass (tab bar) */
  --glass-fill: rgba(255, 251, 246, 0.74);
  --glass-lens: rgba(142, 42, 46, 0.11);
  --glass-edge: rgba(90, 55, 40, 0.16);
  --glass-shine: rgba(255, 255, 255, 0.85);
  --glass-shadow: 0 10px 30px -10px rgba(60, 35, 20, 0.35);
}

[data-theme="dark"] {
  color-scheme: dark;

  --paper: #16110f;           /* espresso, never pure black */
  --paper-deep: #1e1714;
  --card: #231a17;
  --polaroid: #ece4d6;
  --tape: rgba(200, 182, 140, 0.45);

  --ink: #f3eadf;
  --ink-soft: #c4b4a6;
  --ink-faint: #9c8b7e;       /* 5.7:1 on paper, 4.85:1 on their bubble */
  --rule: #2e2420;
  --rule-strong: #44372f;
  --hairline: rgba(255, 240, 225, 0.1);

  --wax: #a83d40;             /* white on it 6.2:1 */
  --wax-deep: #8e2a2e;
  --wax-text: #e39a90;        /* 8.3:1 on paper */
  --wax-tint: rgba(227, 154, 144, 0.12);
  --on-wax: #ffffff;
  --blush: #3a2220;

  --blue: #8fb0d6;
  --sage: #9fbe98;
  --danger: #ff8a7a;

  --bubble-theirs: #2a201c;
  --tick-read: #9fd5ff;

  --shadow-paper: 0 1px 0 rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.35), 0 18px 32px -10px rgba(0, 0, 0, 0.7);
  --shadow-float: 0 10px 24px -8px rgba(0, 0, 0, 0.6);
  --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, 0.5);
  --grain-opacity: 0.06;
  --glass: rgba(22, 17, 15, 0.86);
  --glass-fill: rgba(48, 37, 32, 0.72);
  --glass-lens: rgba(255, 235, 220, 0.11);
  --glass-edge: rgba(255, 235, 220, 0.16);
  --glass-shine: rgba(255, 240, 228, 0.14);
  --glass-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.75);
}
