/* Copyright (c) 2026. All rights reserved. Proprietary: see LICENSE. */
/*
 * Stillwash design tokens — export-ready CSS custom properties.
 *
 * Contrast (WCAG 2.x), measured against the background each pair is used on.
 * AA needs 4.5:1 for normal text, 3:1 for large text and non-text UI.
 *
 * LIGHT                                   ratio  use
 *   ink        #2E3A3F on paper #F6F1E7   10.40  text
 *   muted-text #5F6B73 on paper            4.86  secondary text   (brief #6B7780 = 4.08, kept for icons only)
 *   ink on sage-fill #8BAE99               4.80  primary button label (brief sage #7FA38F + ink = 4.20)
 *   sage-deep  #4A7560 on paper            4.66  on-state of switches, sliders, selected chips, sage text
 *   teal-deep  #47757D on paper            4.54  links
 *   focus      #5E8C93 on paper            3.30  focus ring (non-text, >= 3:1)
 *   terracotta #9A5E4E on paper            4.57  deletion confirmation only
 *
 * EVENING
 *   ink   #ECE7DC on bg #1E2326 12.87 | on surface #262D31 11.34
 *   muted #9AA5AB on bg 6.30 | on surface 5.55
 *   bg #1E2326 on sage #81A18F 5.61 (primary button)
 *   link #82A6AB on bg 6.04 | focus #618A90 on bg 4.19
 *   terracotta #C4836F on bg 5.16
 *
 * NEW PAPER TOKENS (theme system). The ground is a painting surface, not a UI surface, so the pairs
 * that matter are the dark ink of a stroke on the ground and the dimmed ground against the evening page.
 *   paper          ink #2E3A3F on base   ink #2E3A3F on evening   evening ground on evening bg #1E2326
 *   evening-dark   9.85                  6.53                     8.84
 *   aged-parchment 9.46                  6.59                     8.93
 *   watercolour-rag 10.55                7.45                     10.09
 *   Base grounds against the light page #F6F1E7 sit at 1.01 to 1.10 on purpose: the sheet is edged by
 *   its shadow and the --sw-divider hairline, as for the four existing papers.
 *   Grain tokens are opacities (0 to 1), not colours, so they have no contrast ratio.
 *
 * NEW WASH TOKENS (decorative glows behind onboarding and home; carry no text and no meaning).
 * Ratio is of the opaque colour against the page background, ignoring the alpha, for reference only.
 *   --sw-wash-sage  rgb(127 163 143 / .55)  2.47 on light bg #F6F1E7 | 5.69 on evening bg #1E2326
 *   --sw-wash-rose  rgb(217 142 138 / .38)  2.28 on light bg         | 6.19 on evening bg
 *   --sw-wash-ochre rgb(217 162  95 / .36)  2.01 on light bg         | 7.01 on evening bg
 *   Light and evening values equal the glows that base.css hard-coded before; the evening layer
 *   opacity (.22) stays in base.css.
 *
 * NEW TRANSITION TOKEN: --sw-fade (500 ms theme cross-fade; 0 ms under reduced motion and data-still).
 * A duration has no contrast ratio.
 */

:root {
  /* ---------- Colour: brand (light) ---------- */
  --sw-paper: #F6F1E7;
  --sw-surface: rgba(251, 248, 242, 0.85);
  --sw-surface-solid: #FBF8F2;
  --sw-ink: #2E3A3F;
  --sw-muted: #6B7780;          /* icons, non-text marks (4.08:1) */
  --sw-muted-text: #5F6B73;     /* secondary text (4.86:1) */
  --sw-sage: #7FA38F;
  --sw-sage-fill: #8BAE99;      /* primary button fill, ink label */
  --sw-sage-deep: #4A7560;      /* control on-states, sage-coloured text */
  --sw-sage-wash: #E4ECE3;      /* selected chip background */
  --sw-teal: #5E8C93;
  --sw-teal-deep: #47757D;      /* links */
  --sw-ochre: #D9A25F;
  --sw-rose: #D98E8A;
  --sw-divider: #E3DCCD;
  --sw-track: #DDD5C5;          /* slider / switch off track */
  --sw-focus: #5E8C93;
  --sw-terracotta: #9A5E4E;
  --sw-terracotta-wash: #F3E4DC;
  --sw-on-fill: #2E3A3F;        /* text on sage-fill */
  --sw-on-deep: #F6F1E7;        /* text on sage-deep / terracotta */
  --sw-scrim: rgba(46, 58, 63, 0.28);

  /* Decorative glows (.wash in base.css). The theme engine may override these per theme. */
  --sw-wash-sage: rgba(127, 163, 143, 0.55);
  --sw-wash-rose: rgba(217, 142, 138, 0.38);
  --sw-wash-ochre: rgba(217, 162, 95, 0.36);

  /* Painting ground (Cold press base; matches the app token --color-paper) */
  --sw-canvas-paper: #F4F1EA;
  --sw-grain-opacity: 0.5;

  /* ---------- Papers ----------
   * Base: daylight ground, also used for every saved image and journal thumbnail.
   * Evening: dimmed on-screen ground. Grain: opacity of the paper's tile (assets/paper/<id>.jpg),
   * multiplied by --sw-evening-grain-factor under the evening theme.
   * Relative luminance (WCAG 2.1)   base   evening
   *   cold-press #F4F1EA / #CFC6B4  0.881  0.569
   *   hot-press  #F7F5F0 / #D3CCBD  0.914  0.607
   *   rough      #F2EEE6 / #CCC3B1  0.857  0.550
   *   cream      #F5EEDF / #D1C4AA  0.859  0.559
   *   evening-dark    #EEEBE6 / #C6C1B6  0.833  0.535
   *   aged-parchment  #F1E6CF / #D1C19D  0.798  0.541
   *   watercolour-rag #F5F3ED / #D2CEC3  0.896  0.618
   * Every base >= 0.70 and every evening colour >= 0.50. Grain: hot-press < cold-press < rough. */
  --sw-paper-cold-press: #F4F1EA;
  --sw-paper-cold-press-evening: #CFC6B4;
  --sw-paper-cold-press-grain: 0.85;
  --sw-paper-hot-press: #F7F5F0;
  --sw-paper-hot-press-evening: #D3CCBD;
  --sw-paper-hot-press-grain: 0.7;
  --sw-paper-rough: #F2EEE6;
  --sw-paper-rough-evening: #CCC3B1;
  --sw-paper-rough-grain: 1;
  --sw-paper-cream: #F5EEDF;
  --sw-paper-cream-evening: #D1C4AA;
  --sw-paper-cream-grain: 0.85;
  --sw-paper-evening-dark: #EEEBE6;
  --sw-paper-evening-dark-evening: #C6C1B6;
  --sw-paper-evening-dark-grain: 0.8;
  --sw-paper-aged-parchment: #F1E6CF;
  --sw-paper-aged-parchment-evening: #D1C19D;
  --sw-paper-aged-parchment-grain: 0.9;
  --sw-paper-watercolour-rag: #F5F3ED;
  --sw-paper-watercolour-rag-evening: #D2CEC3;
  --sw-paper-watercolour-rag-grain: 0.85;
  --sw-evening-grain-factor: 0.7;
  --sw-paper-tile: 512px;       /* on-screen size of one grain tile */

  /* ---------- Typography ---------- */
  --sw-font-display: "Newsreader", "Iowan Old Style", "Palatino", Georgia, serif;
  --sw-font-ui: "Nunito Sans", "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --sw-weight-light: 300;
  --sw-weight-regular: 400;
  --sw-weight-medium: 500;
  --sw-text-12: 12px;
  --sw-text-14: 14px;
  --sw-text-16: 16px;
  --sw-text-20: 20px;
  --sw-text-28: 28px;
  --sw-text-40: 40px;
  --sw-leading-body: 1.5;
  --sw-leading-display: 1.2;
  --sw-tracking-caps: 0.14em;

  /* ---------- Spacing (8 px grid, 4 px half-step) ---------- */
  --sw-space-half: 4px;
  --sw-space-1: 8px;
  --sw-space-2: 16px;
  --sw-space-3: 24px;
  --sw-space-4: 32px;
  --sw-space-5: 40px;
  --sw-space-6: 48px;
  --sw-space-8: 64px;
  --sw-space-10: 80px;

  /* ---------- Shape ---------- */
  --sw-radius-panel: 14px;
  --sw-radius-frame: 8px;
  --sw-radius-pill: 999px;
  --sw-swatch-primary: 72px;
  --sw-swatch: 32px;
  --sw-target: 44px;

  /* ---------- Depth ---------- */
  --sw-shadow-1: 0 8px 32px rgba(46, 58, 63, 0.08);
  --sw-shadow-2: 0 16px 48px rgba(46, 58, 63, 0.12);
  --sw-shadow-press: 0 2px 12px rgba(46, 58, 63, 0.10);
  --sw-blur: 16px;
  --sw-edge: transparent;       /* hairline used only in high contrast */

  /* ---------- Motion ---------- */
  --sw-dur-1: 300ms;
  --sw-dur-2: 450ms;
  --sw-dur-3: 600ms;
  --sw-dur-scene: 1200ms;       /* end-of-session zoom-out only */
  --sw-fade: 500ms;             /* theme cross-fade; 0ms under reduced motion and data-still (see end of file) */
  --sw-ease: cubic-bezier(0.45, 0, 0.55, 1);
  --sw-breath-in: 4s;
  --sw-breath-out: 6s;
  --sw-breath-cycle: 10s;
  --sw-ui-painting-opacity: 0.15;
}

/* ---------- Evening theme ---------- */
html[data-theme="evening"] {
  --sw-paper: #1E2326;
  --sw-surface: rgba(38, 45, 49, 0.85);
  --sw-surface-solid: #262D31;
  --sw-ink: #ECE7DC;
  --sw-muted: #9AA5AB;
  --sw-muted-text: #9AA5AB;
  --sw-sage: #81A18F;           /* accents softened 10% saturation */
  --sw-sage-fill: #81A18F;
  --sw-sage-deep: #81A18F;
  --sw-sage-wash: #2F3A37;
  --sw-teal: #618A90;
  --sw-teal-deep: #82A6AB;
  --sw-ochre: #D3A165;
  --sw-rose: #D5928E;
  --sw-divider: #343C41;
  --sw-track: #3D464B;
  --sw-focus: #618A90;
  --sw-terracotta: #C4836F;
  --sw-terracotta-wash: #3A2E2B;
  --sw-on-fill: #1E2326;
  --sw-on-deep: #1E2326;
  --sw-scrim: rgba(10, 12, 14, 0.5);
  /* Same glows as light, as before: evening only lowers the layer opacity in base.css. */
  --sw-wash-sage: rgba(127, 163, 143, 0.55);
  --sw-wash-rose: rgba(217, 142, 138, 0.38);
  --sw-wash-ochre: rgba(217, 162, 95, 0.36);
  /* Transparent watercolour needs a light ground, so evening dims the sheet
     instead of inverting it. */
  --sw-canvas-paper: #CFC6B4;
  --sw-grain-opacity: 0.35;
  --sw-shadow-1: 0 8px 32px rgba(0, 0, 0, 0.28);
  --sw-shadow-2: 0 16px 48px rgba(0, 0, 0, 0.36);
  --sw-shadow-press: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* ---------- Accessibility modifiers ---------- */
html[data-contrast="high"] {
  --sw-muted: #2E3A3F;
  --sw-muted-text: #2E3A3F;
  --sw-surface: #FBF8F2;
  --sw-divider: #8A8170;
  --sw-track: #8A8170;
  --sw-focus: #2E5A61;
  --sw-edge: rgba(46, 58, 63, 0.55);
}
html[data-theme="evening"][data-contrast="high"] {
  --sw-muted: #ECE7DC;
  --sw-muted-text: #ECE7DC;
  --sw-surface: #262D31;
  --sw-divider: #7D878C;
  --sw-track: #7D878C;
  --sw-focus: #9FC2C7;
  --sw-edge: rgba(236, 231, 220, 0.55);
}
html[data-targets="large"] {
  --sw-target: 56px;
  --sw-swatch: 40px;
}

/* ---------- Cross-fade between themes ----------
 * Colour variables that change between themes are registered as <color> (inherits, initial = the light
 * value above) so that the browser can interpolate them. Registration does not change what any rule
 * paints; only the serialised computed value of these variables becomes rgb()/rgba() instead of the
 * authored hex. Variables that hold shadows, sizes or opacities are not colours and stay unregistered.
 * Browsers without @property ignore these rules and apply themes instantly. */
@property --sw-paper { syntax: "<color>"; inherits: true; initial-value: #F6F1E7; }
@property --sw-surface { syntax: "<color>"; inherits: true; initial-value: rgba(251, 248, 242, 0.85); }
@property --sw-surface-solid { syntax: "<color>"; inherits: true; initial-value: #FBF8F2; }
@property --sw-ink { syntax: "<color>"; inherits: true; initial-value: #2E3A3F; }
@property --sw-muted { syntax: "<color>"; inherits: true; initial-value: #6B7780; }
@property --sw-muted-text { syntax: "<color>"; inherits: true; initial-value: #5F6B73; }
@property --sw-sage { syntax: "<color>"; inherits: true; initial-value: #7FA38F; }
@property --sw-sage-fill { syntax: "<color>"; inherits: true; initial-value: #8BAE99; }
@property --sw-sage-deep { syntax: "<color>"; inherits: true; initial-value: #4A7560; }
@property --sw-sage-wash { syntax: "<color>"; inherits: true; initial-value: #E4ECE3; }
@property --sw-teal { syntax: "<color>"; inherits: true; initial-value: #5E8C93; }
@property --sw-teal-deep { syntax: "<color>"; inherits: true; initial-value: #47757D; }
@property --sw-ochre { syntax: "<color>"; inherits: true; initial-value: #D9A25F; }
@property --sw-rose { syntax: "<color>"; inherits: true; initial-value: #D98E8A; }
@property --sw-divider { syntax: "<color>"; inherits: true; initial-value: #E3DCCD; }
@property --sw-track { syntax: "<color>"; inherits: true; initial-value: #DDD5C5; }
@property --sw-focus { syntax: "<color>"; inherits: true; initial-value: #5E8C93; }
@property --sw-terracotta { syntax: "<color>"; inherits: true; initial-value: #9A5E4E; }
@property --sw-terracotta-wash { syntax: "<color>"; inherits: true; initial-value: #F3E4DC; }
@property --sw-on-fill { syntax: "<color>"; inherits: true; initial-value: #2E3A3F; }
@property --sw-on-deep { syntax: "<color>"; inherits: true; initial-value: #F6F1E7; }
@property --sw-scrim { syntax: "<color>"; inherits: true; initial-value: rgba(46, 58, 63, 0.28); }
@property --sw-edge { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --sw-canvas-paper { syntax: "<color>"; inherits: true; initial-value: #F4F1EA; }
@property --sw-wash-sage { syntax: "<color>"; inherits: true; initial-value: rgba(127, 163, 143, 0.55); }
@property --sw-wash-rose { syntax: "<color>"; inherits: true; initial-value: rgba(217, 142, 138, 0.38); }
@property --sw-wash-ochre { syntax: "<color>"; inherits: true; initial-value: rgba(217, 162, 95, 0.36); }

html[data-motion="full"] {
  transition:
    --sw-paper var(--sw-fade) var(--sw-ease),
    --sw-surface var(--sw-fade) var(--sw-ease),
    --sw-surface-solid var(--sw-fade) var(--sw-ease),
    --sw-ink var(--sw-fade) var(--sw-ease),
    --sw-muted var(--sw-fade) var(--sw-ease),
    --sw-muted-text var(--sw-fade) var(--sw-ease),
    --sw-sage var(--sw-fade) var(--sw-ease),
    --sw-sage-fill var(--sw-fade) var(--sw-ease),
    --sw-sage-deep var(--sw-fade) var(--sw-ease),
    --sw-sage-wash var(--sw-fade) var(--sw-ease),
    --sw-teal var(--sw-fade) var(--sw-ease),
    --sw-teal-deep var(--sw-fade) var(--sw-ease),
    --sw-ochre var(--sw-fade) var(--sw-ease),
    --sw-rose var(--sw-fade) var(--sw-ease),
    --sw-divider var(--sw-fade) var(--sw-ease),
    --sw-track var(--sw-fade) var(--sw-ease),
    --sw-focus var(--sw-fade) var(--sw-ease),
    --sw-terracotta var(--sw-fade) var(--sw-ease),
    --sw-terracotta-wash var(--sw-fade) var(--sw-ease),
    --sw-on-fill var(--sw-fade) var(--sw-ease),
    --sw-on-deep var(--sw-fade) var(--sw-ease),
    --sw-scrim var(--sw-fade) var(--sw-ease),
    --sw-edge var(--sw-fade) var(--sw-ease),
    --sw-canvas-paper var(--sw-fade) var(--sw-ease),
    --sw-wash-sage var(--sw-fade) var(--sw-ease),
    --sw-wash-rose var(--sw-fade) var(--sw-ease),
    --sw-wash-ochre var(--sw-fade) var(--sw-ease);
}
html[data-motion="reduce"], html[data-still] {
  --sw-fade: 0ms;
  transition: none;
}
