/* MyHome — base layer: fonts, reset, typography, focus, motion.
 *
 * Read tokens.css first; nothing here invents a value.
 */

/* ---- Self-hosted fonts -----------------------------------------------
 * Geist 1.7.2, subset to the Latin ranges the three catalogs need — see
 * web/static/fonts/README.md for what was kept and how to regenerate them.
 *
 * Geist Mono ships one face, Medium. Every mono rule in components.css asks
 * for 600, which resolves to the nearest face at or below it; the design's
 * prototype loads Mono 400 and 500 only, so 500 is exactly what it draws.
 * Regular was never selected by any rule and is not shipped.
 *
 * font-display: swap is deliberate: on a Raspberry Pi over a home LAN the
 * first paint should not wait on a 30 KB woff2.
 */
@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/Geist-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/Geist-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/Geist-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/Geist-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('/static/fonts/GeistMono-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---- Reset ----------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.4;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

/* Controls do not inherit typography by default, and every control in this
 * design is text inside a fixed box, so they must. */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}

a {
  color: inherit;
}

ul,
ol {
  margin: 0;
  padding-left: 1.4em;
}

svg {
  display: block;
  flex: none;
}

/* The UA sheet gives [hidden] display:none at the lowest specificity, so any
 * component rule that sets a display wins over it — and every overlay in this
 * design sets display:flex. Without this, hiding a sheet by setting the
 * attribute does nothing at all. */
[hidden] {
  display: none !important;
}

/* Icons come from one sprite and are sized by their slot, never by the sprite.
 * currentColor throughout, so an icon inherits the ink of whatever it sits in —
 * which is the whole reason the urgency ramp works on icons for free. */
.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Typography scale ------------------------------------------------
 * Transcribed from the handoff. Each rule names the slot it belongs to,
 * because several of them differ by half a pixel and a merged rule would lose
 * that.
 */
.t-screen-title   { font-size: 17px;   font-weight: 600; letter-spacing: -0.2px; }
.t-wordmark       { font-size: 26px;   font-weight: 600; letter-spacing: -0.6px; }
.t-hero           { font-size: 44px;   font-weight: 600; letter-spacing: -1.5px; line-height: 1; }
.t-eod            { font-size: 28px;   font-weight: 600; letter-spacing: -0.5px; font-family: 'Geist Mono', ui-monospace, monospace; }
.t-task-title     { font-size: 14.5px; font-weight: 600; line-height: 1.25; }
.t-task-meta      { font-size: 11.5px; font-weight: 500; }
.t-sheet-title    { font-size: 17px;   font-weight: 600; line-height: 1.25; }
.t-sheet-body     { font-size: 12.5px; line-height: 1.55; }
.t-section        { font-size: 13px;   font-weight: 500; }
.t-eyebrow        { font-size: 11px;   font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; }
.t-pill           { font-size: 10px;   font-weight: 600; letter-spacing: 0.2px; }
.t-action         { font-size: 11px;   font-weight: 600; }
.t-button         { font-size: 14px;   font-weight: 500; }
.t-empty-title    { font-size: 16px;   font-weight: 600; }
.t-empty-body     { font-size: 13px;   line-height: 1.55; }
.t-tab            { font-size: 10px;   font-weight: 500; }
.t-mono           { font-family: 'Geist Mono', ui-monospace, monospace; }

/* ---- Truncation helpers ----------------------------------------------
 * The fixed-geometry rule is enforced by these two and by explicit heights.
 * Anything with a fixed width or height carries one of them.
 */
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

/* ---- Focus -----------------------------------------------------------
 * The handoff is explicit: keyboard focus must be styled, never left to the
 * browser default. :focus-visible rather than :focus so a tap does not leave a
 * ring behind on a touch device.
 *
 * The ring is an outline, not the handoff's 3px box-shadow at 25% grey. That
 * shadow measured 1.2:1 against the page — WCAG 1.4.11 asks 3:1 of a focus
 * indicator — and every component that sets its own box-shadow (buttons,
 * inputs, the segmented control) silently replaced it, so half the controls
 * showed no focus at all. No component sets an outline, so this one survives.
 * The soft halo stays underneath as decoration.
 */
:root {
  --focus: oklch(0.45 0 0);
}

[data-theme='dark'] {
  --focus: oklch(0.82 0 0);
}

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

/* On a card the neutral ring disappears into the fill, so focus there is drawn
 * in the card's own ink, which is held to 4.5:1 against that fill. */
.card-surface :focus-visible,
.card-surface:focus-visible {
  outline-color: var(--ink, var(--focus));
}

/* ---- Keyframes -------------------------------------------------------- */
@keyframes shadIn   { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
/* + 24px since wave 7: the sheet floats 8px above the bottom edge (and the
 * home indicator), and starting at exactly its own height left that sliver
 * of it on screen in the first frame. */
@keyframes sheetUp  { from { transform: translateY(calc(100% + 24px)); } to { transform: translateY(0); } }
@keyframes scrimIn  { from { opacity: 0; }                             to { opacity: 1; } }
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes zoomIn   { from { opacity: 0; transform: scale(0.94); }     to { opacity: 1; transform: scale(1); } }
@keyframes barGrow  { from { width: 0; } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes pulse    { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes confetti {
  0%   { transform: translate(0, 0) rotate(0);                              opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) rotate(var(--rot));      opacity: 0; }
}

/* ---- Reduced motion ---------------------------------------------------
 * Two layers, as the handoff asks for. This is the backstop: it clamps
 * anything that still animates. The first layer is in JS (app.js), which skips
 * rendering decorative DOM — confetti in particular — entirely, because an
 * animation clamped to 0.01ms still puts sixteen shards on the screen for one
 * frame and still costs the layout.
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
