/* MyHome — design tokens.
 *
 * Every value here is transcribed from the design handoff's token tables. None
 * of them is a judgement call, and none of them should be edited to make a
 * component look right: if a component needs a different value, the component
 * is wrong.
 *
 * Dark mode is a genuine second token set, never a filter inversion (ADR-0011).
 * The two sets differ in more than lightness — the shadows are heavier, the
 * borders switch from opaque grey to translucent white, and the card ink flips
 * in the opposite direction at the top of the urgency ramp.
 */

:root {
  /* ---- Radii --------------------------------------------------------
   * Wave 7 (Liquid Glass) rounds everything up: concentric with the device
   * corner, and pills wherever a control is a button. */
  --radius: 20px;
  --radius-sm: 12px;
  --radius-lg: 28px;

  /* ---- Chrome, light ------------------------------------------------ */
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  /* System blue since wave 7 (was neutral 0.205): the one colour the chrome
   * owns, so the tint on "+ Aufgabe" and Speichern reads as the action. */
  --primary: oklch(0.55 0.2 256);
  --primary-foreground: oklch(1 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.53 0 0);
  --accent: oklch(0.965 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(0.918 0 0);
  --input: oklch(0.9 0 0);
  --ring: oklch(0.708 0 0);

  /* ---- Shadow and scrim, light -------------------------------------- */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.06);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 12px 24px -6px rgb(0 0 0 / 0.18), 0 4px 8px -4px rgb(0 0 0 / 0.12);
  /* Lighter since wave 7: a sheet is inset glass now, and a partial sheet
   * should dim the screen behind it, not black it out. */
  --scrim: rgb(0 0 0 / 0.28);

  /* ---- Liquid Glass, light (wave 7, ADR-0016) -------------------------
   * Regular glass only, never "clear": the more opaque of Apple's two
   * materials, because the published criticism of the style is contrast.
   * The effect is blur, saturation and a specular edge — nothing here
   * depends on refraction, which only Chromium can draw on the web.
   * --glass-thick-* is for the larger surfaces (sheets, the celebration
   * card): larger glass is thicker glass. --glass-tint-* is the main action
   * only ("+ Aufgabe", a sheet's primary button). */
  --glass-bg: rgb(255 255 255 / 0.56);
  --glass-thick-bg: rgb(250 250 252 / 0.76);
  --glass-sheen: linear-gradient(180deg, rgb(255 255 255 / 0.55), rgb(255 255 255 / 0.06) 52%, rgb(255 255 255 / 0.2));
  --glass-filter: blur(14px) saturate(190%) brightness(1.04);
  --glass-thick-filter: blur(30px) saturate(180%);
  --glass-shadow: inset 0 1px 0 rgb(255 255 255 / 0.95), inset 0 -1px 1px rgb(255 255 255 / 0.35),
    inset 0 0 0 0.5px rgb(255 255 255 / 0.55), 0 8px 28px rgb(0 0 0 / 0.14), 0 1px 4px rgb(0 0 0 / 0.08);
  --glass-border: 0.5px solid rgb(0 0 0 / 0.07);
  --glass-pill: rgb(0 0 0 / 0.075);      /* the selected tab's lift        */
  --glass-grip: rgb(0 0 0 / 0.22);
  --glass-tint-bg: oklch(0.55 0.2 256 / 0.86);
  --glass-tint-shadow: inset 0 1px 0 rgb(255 255 255 / 0.55), inset 0 -1px 1px rgb(255 255 255 / 0.2),
    0 10px 26px oklch(0.55 0.2 256 / 0.36), 0 2px 6px rgb(0 0 0 / 0.12);
  --tint-fg: oklch(1 0 0);

  /* Speichern on the task detail: solid, never glass, never faded when
   * disabled — product feedback was that it must read as a solid button. */
  --save-bg: oklch(0.55 0.2 256);
  --save-fg: oklch(1 0 0);
  --save-shadow: 0 4px 14px oklch(0.55 0.2 256 / 0.3);

  /* The current tab's icon and label on the glass capsule. A step darker
   * than --primary: the design's 0.55 blue measured 4.2:1 under the selected
   * tab's lift, short of 4.5:1 for a 10px label. Still reads as the same
   * blue. */
  --tab-active: oklch(0.5 0.2 256);

  /* The iOS switch track. */
  --switch-on: oklch(0.72 0.19 145);

  /* Neon glow radius on task cards: none in light. */
  --glow: 0px;

  /* The screen behind the content. Plain in light; dark mode lays colour
   * drops over it so the glass has something to show through. */
  --app-bg: var(--background);

  /* ---- Motion -------------------------------------------------------- */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Fixed geometry ------------------------------------------------
   * Non-negotiable. The product feedback behind these is that no control may
   * grow with its content, in any of the three languages. Anything that reads
   * a length from one of these must also state an overflow rule.
   */
  --av: 56px;        /* row avatar                                        */
  --badge-h: 20px;   /* status pill                                       */
  --act-h: 32px;     /* action button                                     */
  --rail: 104px;     /* right column of a task row                        */
  --row-h: 96px;     /* open task row                                     */
  --row-sm: 64px;    /* done task row, category row, user row, cadence row */

  /* Geometry the handoff's table states but does not name as a token. Held
   * here so a component never spells a magic number twice. */
  --row-compact: 56px;   /* week / month row                              */
  --snooze-h: 22px;      /* snooze button under the action                */
  --control-h: 44px;     /* button and text input: HIG minimum hit target */
  --fab-h: 48px;
  --tabbar-h: 66px;
  --icon-btn: 32px;      /* header and stepper icon buttons               */
  --title-h: 36px;       /* two clamped lines of task title               */
  --meta-h: 15px;        /* one ellipsised line of meta                   */
  --cat-chip-w: 112px;
  --cat-chip-h: 36px;
  --assignee-w: 76px;
  --assignee-h: 88px;
  --status-opt-h: 38px;
  --role-pill-w: 72px;
  --switch-w: 51px;      /* iOS switch, 27px knob                         */
  --switch-h: 31px;
  --header-h: 58px;      /* the overlay header; content starts below it   */
  --tab-label-max: 66px;

  /* ---- Category / urgency ramp, light --------------------------------
   * Each category owns a hue; urgency moves lightness and chroma inside that
   * hue across five levels, so the category stays identifiable the whole way
   * up. A card sets --hue and --lvl, and everything else follows.
   */
  --fillL0: 0.90;  --fillC0: 0.090;  --edgeL0: 0.78;  --edgeC0: 0.120;
  --fillL1: 0.84;  --fillC1: 0.120;  --edgeL1: 0.72;  --edgeC1: 0.150;
  --fillL2: 0.76;  --fillC2: 0.150;  --edgeL2: 0.64;  --edgeC2: 0.170;
  --fillL3: 0.66;  --fillC3: 0.175;  --edgeL3: 0.55;  --edgeC3: 0.190;
  --fillL4: 0.56;  --fillC4: 0.195;  --edgeL4: 0.46;  --edgeC4: 0.200;

  /* Card ink, light: dark up to level 2, flipping to near-white at 3–4.
   *
   * These are the handoff's values and they are kept verbatim, but they are
   * not what paints the text. The server computes a per-hue ink that is
   * guaranteed to clear 4.5:1 and passes it in as --ink, because the tabled
   * value does not hold on every hue — see web/templates/urgency.go. They
   * remain here as the documented default and as the fallback for any element
   * rendered without a computed ink.
   */
  --inkL: 0.28;   --inkC: 0.08;
  --inkL3: 0.99;  --inkC3: 0.012;
  --inkL4: 0.99;  --inkC4: 0.012;

  /* ---- Derived card colours ------------------------------------------
   * The handoff derives five more colours from a category's hue. They are
   * written out at each use site in components.css rather than aliased here,
   * and that is not an oversight.
   *
   * A custom property whose value contains var() is substituted at computed-
   * value time *on the element that declares it*. An alias declared here would
   * therefore resolve var(--hue) against :root — where the hue is 0 — and
   * inherit that one resolved colour down to every card, so every category
   * would come out the same shade of red. The values are recorded below as
   * comments so the numbers still live in one place.
   *
   *   label on a hue-filled surface  oklch(0.99 0.012 var(--hue))
   *   action button fill, chip ink   oklch(0.32 0.09  var(--hue))
   *   row avatar fill                oklch(0.60 0.17  var(--hue))
   *   status dot below the flip      oklch(0.45 0.16  var(--hue))
   *   flat category swatch           oklch(0.62 0.16  var(--hue))
   */

  /* Neutral default so a component that forgets to set --hue renders grey
   * rather than failing. An unset custom property inside oklch() invalidates
   * the whole declaration, which is a far more confusing failure. */
  --hue: 0;
}

[data-theme='dark'] {
  /* ---- Chrome, dark --------------------------------------------------- */
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --primary: oklch(0.56 0.19 256);
  --primary-foreground: oklch(1 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  /* Brighter since wave 7, for readability over the colour drops. */
  --muted-foreground: oklch(0.82 0 0);
  --accent: oklch(0.28 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.145 0 0);
  --border: oklch(1 0 0 / 12%);
  --input: oklch(1 0 0 / 16%);
  --ring: oklch(0.556 0 0);

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.35);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.45);
  --shadow-lg: 0 12px 24px -6px rgb(0 0 0 / 0.6);
  --scrim: rgb(0 0 0 / 0.5);

  /* ---- Liquid Glass, dark ---------------------------------------------
   * Darker and more opaque than the light glass: a translucent dark surface
   * over neon cards would otherwise take their colour as its own. */
  --glass-bg: rgb(26 26 32 / 0.74);
  --glass-thick-bg: rgb(22 22 28 / 0.88);
  --glass-sheen: linear-gradient(180deg, rgb(255 255 255 / 0.16), rgb(255 255 255 / 0.02) 52%, rgb(255 255 255 / 0.07));
  --glass-shadow: inset 0 1px 0 rgb(255 255 255 / 0.24), inset 0 -1px 1px rgb(255 255 255 / 0.07),
    inset 0 0 0 0.5px rgb(255 255 255 / 0.14), 0 8px 28px rgb(0 0 0 / 0.5);
  --glass-border: 0.5px solid rgb(255 255 255 / 0.08);
  --glass-pill: rgb(255 255 255 / 0.13);
  --glass-grip: rgb(255 255 255 / 0.3);
  --glass-tint-bg: oklch(0.56 0.19 256 / 0.88);

  /* Neon blue with dark ink: white on a blue this light would fail 4.5:1. */
  --save-bg: oklch(0.74 0.17 245);
  --save-fg: oklch(0.17 0.05 256);
  --save-shadow: 0 0 22px -2px oklch(0.74 0.19 245 / 0.7), 0 0 0 1px oklch(0.86 0.12 240 / 0.6) inset;

  --glow: 20px;

  /* Lighter than --primary: the design's 0.56 blue measured about 2.5:1 on
   * the dark capsule under the selected tab's lift, too little for a 10px
   * label. The save button's neon blue family, which clears 4.5:1 there. */
  --tab-active: oklch(0.76 0.14 250);

  /* Eight colour drops in the category hues, the prototype's list verbatim. */
  --app-bg:
    radial-gradient(70px 70px at 14% 22%, oklch(0.68 0.19 27 / 0.33), transparent 70%),
    radial-gradient(120px 120px at 86% 14%, oklch(0.66 0.16 195 / 0.25), transparent 70%),
    radial-gradient(46px 46px at 72% 38%, oklch(0.82 0.16 85 / 0.3), transparent 70%),
    radial-gradient(150px 150px at 8% 62%, oklch(0.6 0.2 295 / 0.24), transparent 70%),
    radial-gradient(60px 60px at 58% 70%, oklch(0.72 0.18 145 / 0.27), transparent 70%),
    radial-gradient(130px 130px at 94% 84%, oklch(0.64 0.2 350 / 0.23), transparent 70%),
    radial-gradient(38px 38px at 34% 90%, oklch(0.78 0.15 60 / 0.3), transparent 70%),
    radial-gradient(90px 90px at 40% 8%, oklch(0.62 0.18 256 / 0.24), transparent 70%),
    var(--background);

  /* ---- Category / urgency ramp, dark: neon (wave 7) --------------------
   * The ramp runs the other way: urgency gets lighter, not darker. Since
   * wave 7 the fills are deeper and more saturated and the rims bright, so
   * a card glows (--glow) in its own hue. urgency.go holds the same table
   * and computes the ink that keeps 4.5:1 on it.
   */
  --fillL0: 0.31;  --fillC0: 0.110;  --edgeL0: 0.64;  --edgeC0: 0.170;
  --fillL1: 0.35;  --fillC1: 0.140;  --edgeL1: 0.70;  --edgeC1: 0.190;
  --fillL2: 0.41;  --fillC2: 0.170;  --edgeL2: 0.76;  --edgeC2: 0.210;
  --fillL3: 0.48;  --fillC3: 0.200;  --edgeL3: 0.82;  --edgeC3: 0.220;
  --fillL4: 0.66;  --fillC4: 0.220;  --edgeL4: 0.88;  --edgeC4: 0.200;

  /* Card ink, dark: near-white up to level 3, flipping *dark* at level 4,
   * because by then the fill has become light enough that white would fail. */
  --inkL: 0.97;   --inkC: 0.02;
  --inkL3: 0.98;  --inkC3: 0.015;
  --inkL4: 0.18;  --inkC4: 0.045;
}

/* ---- Bedienungshilfen (ADR-0016) --------------------------------------
 * theme.js puts the effective state on <html>: the account's switch or the
 * operating system's setting, whichever asks for more. The @media blocks are
 * the same rule for a browser that runs no script.
 *
 * Reduced transparency swaps every glass surface for its solid twin — the
 * card colour, no blur, no sheen — so nothing on the control layer depends
 * on backdrop-filter to be legible. Increased contrast outlines the glass in
 * the foreground colour and darkens secondary text.
 */
[data-glass='solid'] {
  --glass-bg: var(--card);
  --glass-thick-bg: var(--card);
  --glass-sheen: linear-gradient(transparent, transparent);
  --glass-filter: none;
  --glass-thick-filter: none;
  --glass-tint-bg: var(--primary);
}

[data-contrast='more'] {
  --glass-border: 1.5px solid var(--foreground);
  --muted-foreground: oklch(0.38 0 0);
}

[data-theme='dark'][data-contrast='more'] {
  --muted-foreground: oklch(0.88 0 0);
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --glass-bg: var(--card);
    --glass-thick-bg: var(--card);
    --glass-sheen: linear-gradient(transparent, transparent);
    --glass-filter: none;
    --glass-thick-filter: none;
    --glass-tint-bg: var(--primary);
  }
}

@media (prefers-contrast: more) {
  :root {
    --glass-border: 1.5px solid var(--foreground);
    --muted-foreground: oklch(0.38 0 0);
  }

  [data-theme='dark'] {
    --muted-foreground: oklch(0.88 0 0);
  }
}

/* The handoff's seed categories. Named so a fixture, a migration or a test can
 * refer to "the Küche hue" instead of to the number 27. */
:root {
  --hue-kueche: 27;
  --hue-bad: 195;
  --hue-einkauf: 85;
  --hue-garten: 145;
  --hue-muell: 295;
}
