/* House style, drop-in layer.
   Generated from /Users/jm/dev/house-style/DESIGN.md, which is the spec: read
   it before using this. Two ways in:

     1. Retrofit. Link this first, then remap the app's own tokens to the --h-*
        ones in your own stylesheet ( --card-bg: var(--h-paper) and so on ), and
        override the app's component rules where they fight.
     2. New build. Link this and use the h- classes below.

   Fonts are the Geist stand-ins. KH Teka and KH Teka Mono are the real faces
   and need a KH Type license. */

@font-face { font-family: "Geist"; src: url("https://cdn.jsdelivr.net/npm/geist@1.4.2/dist/fonts/geist-sans/Geist-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Geist"; src: url("https://cdn.jsdelivr.net/npm/geist@1.4.2/dist/fonts/geist-sans/Geist-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("https://cdn.jsdelivr.net/npm/geist@1.4.2/dist/fonts/geist-mono/GeistMono-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --h-ground: #9A9A9A;
  --h-paper: #E9E9E9;
  --h-paper-2: #DEDEDE;
  --h-ink: #202020;
  --h-raised: #FFFFFF;
  --h-line: #BBBBBB;
  --h-line-ink: #4F4F4F;
  --h-text: #202020;
  --h-text-2: #5C5C5C;
  --h-on-ink: #FFFFFF;
  --h-on-ink-2: #9A9A9A;

  --h-blue: #379DEF;
  --h-orange: #FF5A33;
  --h-yellow: #FFB800;
  --h-green: #18AC65;
  /* Extended hues, for a screen with more than four sections. Same register,
     ink text on every one. */
  --h-cyan: #3FD0DF;
  --h-violet: #A88CFF;
  --h-pink: #FF4D93;

  --h-success: #1C8551;
  --h-warning: #A85A0C;
  --h-danger: #C93A25;
  --h-lift: 0 8px 24px rgb(0 0 0 / .12);
  --h-backdrop: rgb(0 0 0 / .5);

  --h-sans: "KH Teka", "Geist", system-ui, sans-serif;
  --h-mono: "KH Teka Mono", "Geist Mono", ui-monospace, monospace;
  /* Zero tracking on text. KH Teka Mono ships loose and takes -0.06em as a
     correction to the face once it is licensed; Geist Mono needs none. */
  --h-mono-track: 0;

  /* One musical ratio, fluid: a minor third ( 1.2 ) on a 390 phone, a major
     third ( 1.25 ) at 1440, body 16 to 17. Steps -1, 0, 1, then 4 and 5: no
     mid tier. Generated by the utopia skill; never hand-edit the middle term.
     @link https://utopia.fyi/type/calculator?c=390,16,1.2,1440,17,1.25,5,2,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12 */
  --h-step--1: clamp(0.8333rem, 0.8271rem + 0.0254vw, 0.85rem);
  --h-step-0: clamp(1rem, 0.9768rem + 0.0952vw, 1.0625rem);
  --h-step-1: clamp(1.2rem, 1.1524rem + 0.1952vw, 1.3281rem);
  --h-step-4: clamp(2.0736rem, 1.8803rem + 0.793vw, 2.594rem);
  --h-step-5: clamp(2.4883rem, 2.2082rem + 1.1492vw, 3.2425rem);

  /* Line heights on the 4px ladder at both poles ( 16, 24, 24 to 28, 40 to
     48, 40 to 52 ). Sizes are free; lines are not. */
  --h-lh--1: 1rem;
  --h-lh-0: 1.5rem;
  --h-lh-1: clamp(1.5rem, 1.4071rem + 0.381vw, 1.75rem);
  --h-lh-4: clamp(2.5rem, 2.3143rem + 0.7619vw, 3rem);
  --h-lh-5: clamp(2.5rem, 2.2214rem + 1.1429vw, 3.25rem);

  /* The role tokens, each pointing at a step. micro and sm share step -1:
     face and color separate a badge from a label, not a 2px size step. */
  --h-t-micro: var(--h-step--1);
  --h-t-sm: var(--h-step--1);
  --h-t-md: var(--h-step-0);
  --h-t-row: var(--h-step-1);
  --h-t-nav: var(--h-step-1);
  --h-t-title: var(--h-step-4);
  --h-t-figure: var(--h-step-5);
  --h-t-display: clamp(64px, 11vw, 176px);

  --h-gutter: 8px;
  --h-r-xs: 4px;
  --h-r-sm: 8px;
  --h-r-md: 12px;
  --h-r-lg: 16px;
  --h-r-xl: 24px;
  --h-r-tile: 40px;
  --h-r-tall: 88px;
  --h-r-hero: 160px;
  --h-r-full: 9999px;

  --h-ease: cubic-bezier(.45, 0, .55, 1);
  --h-ease-enter: cubic-bezier(.23, .09, .08, 1.13);
  --h-dur-press: 75ms;
  --h-dur-snap: 150ms;
  --h-dur-modal: 200ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --h-handle: #FFFFFF;
    --h-ground: #141414;
    --h-paper: #252525;
    --h-paper-2: #2A2A2A;
    --h-raised: #363636;
    --h-line: #2A2A2A;
    --h-text: #FFFFFF;
    --h-text-2: #9A9A9A;
    --h-lift: none;
  }
}

[data-theme="dark"] {
  --h-handle: #FFFFFF;
  --h-ground: #141414;
  --h-paper: #252525;
  --h-paper-2: #2A2A2A;
  --h-raised: #363636;
  --h-line: #2A2A2A;
  --h-text: #FFFFFF;
  --h-text-2: #9A9A9A;
  --h-lift: none;
}

@media (max-width: 720px) {
  :root { --h-r-tall: 40px; --h-r-hero: 64px; }
}

/* ── Page ── */
.h-page {
  background: var(--h-ground);
  color: var(--h-text);
  font-family: var(--h-sans);
  font-size: var(--h-t-md);
  line-height: var(--h-lh-0);
  padding: var(--h-gutter);
}
.h-col { max-width: 800px; margin: 0 auto; }
.h-col--form { max-width: 480px; }
.h-col--wide { max-width: 1600px; }
.h-stack > * + * { margin-top: var(--h-gutter); }
.h-stack--tight > * + * { margin-top: 4px; }

/* ── Tiles ── */
.h-tile {
  background: var(--h-paper);
  border-radius: var(--h-r-tile);
  padding: 24px;
}
.h-tile--ink { background: var(--h-ink); color: var(--h-on-ink); }
.h-tile--blue { background: var(--h-blue); color: var(--h-ink); }
.h-tile--orange { background: var(--h-orange); color: var(--h-ink); }
.h-tile--yellow { background: var(--h-yellow); color: var(--h-ink); }
.h-tile--green { background: var(--h-green); color: var(--h-ink); }
.h-tile--cyan { background: var(--h-cyan); color: var(--h-ink); }
.h-tile--violet { background: var(--h-violet); color: var(--h-ink); }
.h-tile--pink { background: var(--h-pink); color: var(--h-ink); }
.h-tile--tall { border-radius: var(--h-r-tall); }
.h-tile--hero { border-radius: var(--h-r-hero); }
@media (min-width: 641px) { .h-tile { padding: 40px; } }

/* ── Type ──
   Every text class is cap trimmed: its box runs cap line to baseline, so a
   gap written in CSS is the gap the eye reads. 12 is the tightest gap between
   two runs of body, 16 separates, 24 and up divides. .h-trim does the same
   for any other run of text. Never trim a button, chip or badge: their box is
   already the edge. */
.h-title, .h-row-title, .h-figure, .h-display, .h-micro, .h-trim { text-box: trim-both cap alphabetic; }
.h-title { font-size: var(--h-t-title); line-height: var(--h-lh-4); letter-spacing: -0.02em; font-weight: 400; }
.h-row-title { font-size: var(--h-t-row); line-height: var(--h-lh-1); font-weight: 500; }
.h-figure { font-size: var(--h-t-figure); line-height: var(--h-lh-5); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.h-figure .h-frac { color: var(--h-text-2); }
.h-display { font-size: var(--h-t-display); line-height: .92; letter-spacing: -0.035em; }
.h-mono { font-family: var(--h-mono); letter-spacing: var(--h-mono-track); }
.h-micro { font-size: var(--h-t-micro); line-height: var(--h-lh--1); color: var(--h-text-2); }
.h-dim { color: var(--h-text-2); }

/* ── Chips and buttons ── */
.h-chiprow { display: flex; flex-wrap: wrap; gap: 4px; }
.h-chip {
  height: 48px; padding: 0 22px;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--h-paper); color: var(--h-text);
  border: none; border-radius: var(--h-r-full);
  font-family: var(--h-mono); font-size: var(--h-t-nav); line-height: var(--h-lh-1);
  cursor: pointer;
}
.h-chip--ink { background: var(--h-ink); color: var(--h-on-ink); }
.h-chip--blue { background: var(--h-blue); color: var(--h-ink); }
.h-chip--orange { background: var(--h-orange); color: var(--h-ink); }
.h-chip--yellow { background: var(--h-yellow); color: var(--h-ink); }
.h-chip--green { background: var(--h-green); color: var(--h-ink); }
.h-chip--cyan { background: var(--h-cyan); color: var(--h-ink); }
.h-chip--violet { background: var(--h-violet); color: var(--h-ink); }
.h-chip--pink { background: var(--h-pink); color: var(--h-ink); }

.h-btn {
  height: 48px; padding: 0 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--h-mono); font-size: var(--h-t-md); font-weight: 400;
  letter-spacing: var(--h-mono-track);
  border-radius: var(--h-r-lg); cursor: pointer;
  background: var(--h-blue); color: var(--h-ink); border: 1px solid var(--h-blue);
  transition: filter var(--h-dur-snap) var(--h-ease), transform var(--h-dur-press) var(--h-ease);
}
.h-btn:hover { filter: brightness(.94); }
.h-btn:active { transform: scale(.98); }
.h-btn:disabled { opacity: .4; cursor: default; }
.h-btn--lg { height: 56px; padding: 0 24px; }
.h-btn--sm { height: 40px; padding: 0 16px; font-size: var(--h-t-sm); border-radius: var(--h-r-md); }
.h-btn--ink { background: var(--h-ink); color: var(--h-on-ink); border-color: var(--h-ink); }
.h-btn--paper { background: var(--h-paper); color: var(--h-text); border-color: var(--h-paper); }
.h-btn--ghost { background: transparent; color: var(--h-text); border-color: var(--h-line); }
.h-btn--danger { background: transparent; color: var(--h-danger); border-color: var(--h-danger); }
.h-btn--icon { width: 40px; height: 40px; padding: 0; border-radius: var(--h-r-md); }
.h-btn--block { width: 100%; }

:where(.h-btn, .h-chip, .h-seg button, .h-field, .h-toggle):focus-visible {
  outline: 2px solid var(--h-blue); outline-offset: 2px;
}

/* ── Segmented control ── */
.h-seg {
  display: flex; align-items: center; gap: 4px;
  height: 48px; max-width: 360px; padding: 4px;
  background: var(--h-paper-2); border-radius: var(--h-r-full);
}
.h-seg button {
  flex: 1 1 0; height: 40px; padding: 0 20px;
  border: none; background: none; border-radius: var(--h-r-full);
  font-family: var(--h-mono); font-size: var(--h-t-md);
  letter-spacing: var(--h-mono-track); color: var(--h-text-2); cursor: pointer;
  transition: background-color var(--h-dur-snap) var(--h-ease), color var(--h-dur-snap) var(--h-ease);
}
.h-seg button[aria-pressed="true"], .h-seg button.is-active {
  background: var(--h-raised); color: var(--h-text);
}
@media (max-width: 480px) { .h-seg button { padding: 0 8px; font-size: var(--h-t-sm); } }

/* ── Fields ── */
.h-field {
  width: 100%; height: 56px; padding: 0 20px;
  background: var(--h-paper); color: var(--h-text);
  border: none; border-radius: var(--h-r-lg);
  font-family: var(--h-sans); font-size: var(--h-t-md);
}
.h-field::placeholder { color: var(--h-text-2); }
.h-field--on-paper { border: 1px solid var(--h-line); }
.h-label { display: block; font-size: var(--h-t-sm); margin-bottom: 8px; }
.h-help { font-size: var(--h-t-micro); color: var(--h-text-2); margin-top: 8px; }
.h-help--error { color: var(--h-danger); }

/* ── Rows ── */
.h-rows { display: flex; flex-direction: column; gap: 4px; }
.h-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 0 16px;
  background: var(--h-paper-2); border-radius: var(--h-r-lg);
}
.h-row--tall { min-height: 64px; }
.h-row__tile {
  flex: 0 0 32px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--h-r-sm);
  background: var(--sec, var(--h-paper)); color: var(--h-ink);
  font-family: var(--h-mono); font-size: var(--h-t-md); font-weight: 500;
  letter-spacing: var(--h-mono-track);
}
.h-row__end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.h-row__meta { font-family: var(--h-mono); font-size: var(--h-t-micro); color: var(--h-text-2); }

/* ── Disclosure ── */
.h-disc { background: var(--h-paper); border-radius: var(--h-r-lg); padding: 0 12px; }
.h-disc[open], .h-disc.is-open { border-radius: var(--h-r-tile); padding-bottom: 8px; }
.h-disc__head {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 0 4px; cursor: pointer;
}
.h-disc__chevron { width: 24px; height: 24px; color: var(--h-text-2); transition: transform .25s var(--h-ease); }
.h-disc[open] .h-disc__chevron, .h-disc.is-open .h-disc__chevron { transform: rotate(90deg); }
.h-card {
  background: var(--h-paper-2); border-radius: var(--h-r-md);
  padding: 12px; margin-bottom: 4px;
}
.h-card:last-child { margin-bottom: 0; }

/* ── Badge ── */
.h-badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px;
  border-radius: var(--h-r-xs);
  font-family: var(--h-mono); font-size: var(--h-t-micro);
  letter-spacing: var(--h-mono-track);
  background: var(--h-paper-2); color: var(--h-text-2);
}
.h-badge--blue { background: var(--h-blue); color: var(--h-ink); }
.h-badge--orange { background: var(--h-orange); color: var(--h-ink); }
.h-badge--yellow { background: var(--h-yellow); color: var(--h-ink); }
.h-badge--green { background: var(--h-green); color: var(--h-ink); }

/* ── Toggle, checkbox ── */
.h-toggle {
  appearance: none; width: 44px; height: 24px; padding: 2px;
  background: var(--h-paper-2); border: 1px solid var(--h-line);
  border-radius: var(--h-r-full); cursor: pointer;
  transition: background-color var(--h-dur-snap) var(--h-ease);
}
.h-toggle::after {
  content: ""; display: block; width: 20px; height: 20px;
  border-radius: var(--h-r-full); background: var(--h-raised);
  transition: transform var(--h-dur-snap) var(--h-ease);
}
.h-toggle:checked { background: var(--h-blue); border-color: var(--h-blue); }
.h-toggle:checked::after { transform: translateX(20px); background: var(--h-ink); }
.h-check {
  appearance: none; width: 24px; height: 24px;
  border: 1px solid var(--h-line); border-radius: 6px;
  background: var(--h-raised); cursor: pointer;
}
.h-check:checked {
  background: var(--h-blue) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23202020' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12.5l4.5 4.5L19 7'/></svg>") center / 16px no-repeat;
  border-color: var(--h-blue);
}

/* ── Slider ──
   A tall track with four dots at 20 / 40 / 60 / 80, a fill to the value and a
   capsule handle. Put the label and a static value above it; nothing animates
   a number while you drag. */
.h-slider { position: relative; height: 56px; border-radius: var(--h-r-lg); background: var(--h-paper-2); overflow: hidden; }
.h-slider__fill { position: absolute; inset: 0 auto 0 0; width: var(--h-val, 50%); background: var(--h-paper); }
[data-theme="dark"] .h-slider__fill { background: var(--h-raised); }
.h-slider__dots {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(circle 2px at 20% 50%, var(--h-text-2) 99%, transparent 100%),
    radial-gradient(circle 2px at 40% 50%, var(--h-text-2) 99%, transparent 100%),
    radial-gradient(circle 2px at 60% 50%, var(--h-text-2) 99%, transparent 100%),
    radial-gradient(circle 2px at 80% 50%, var(--h-text-2) 99%, transparent 100%);
  opacity: .5;
}
.h-slider input[type="range"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; appearance: none; background: none; cursor: ew-resize;
}
.h-slider input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 12px; height: 32px;
  border-radius: var(--h-r-full);
  background: var(--h-handle, var(--h-raised)); border: 2px solid var(--h-blue);
  box-shadow: none; cursor: ew-resize;
}
.h-slider input[type="range"]::-moz-range-thumb {
  width: 12px; height: 32px; border-radius: var(--h-r-full);
  background: var(--h-handle, var(--h-raised)); border: 2px solid var(--h-blue);
}
.h-slider__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.h-slider__head .h-val { font-family: var(--h-mono); font-size: var(--h-t-sm); letter-spacing: var(--h-mono-track); color: var(--h-text-2); font-variant-numeric: tabular-nums; }

/* Compact variant for a dense tool panel: the same channel at 32, a 8x20
   handle, label and value on one line above it. */
.h-slider--sm { height: 32px; border-radius: var(--h-r-md); }
.h-slider--sm input[type="range"]::-webkit-slider-thumb { width: 8px; height: 20px; }
.h-slider--sm input[type="range"]::-moz-range-thumb { width: 8px; height: 20px; }

/* ── Modal, toast, meter ── */
.h-backdrop { position: fixed; inset: 0; background: var(--h-backdrop); backdrop-filter: blur(10px); display: grid; place-items: center; padding: var(--h-gutter); }
.h-modal { width: min(480px, 100%); background: var(--h-paper); border-radius: var(--h-r-xl); padding: 24px; }
[data-theme="dark"] .h-modal { background: var(--h-ink); color: var(--h-on-ink); }
.h-toast {
  display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px;
  background: var(--h-ink); color: var(--h-on-ink); border-radius: var(--h-r-full);
  font-size: var(--h-t-sm);
}
.h-meter { height: 8px; border-radius: var(--h-r-full); background: var(--h-paper-2); overflow: hidden; }
.h-meter > span { display: block; height: 100%; background: var(--h-blue); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
