/* Tinewise design tokens v0
   ---------------------------------------------------------------
   Tokens, base element styles, the info-strip component, and a
   handful of primitives (chip, button, table, label) that every
   screen needs. Page-specific layout lives in each page.
   Dark is the default theme. Set <html data-theme="paper"> for paper.
   See SYSTEM.md for the rules behind every value here. */

@import url('https://fonts.googleapis.com/css2?family=Archivo:ital,wdth,wght@0,62..125,100..900;1,62..125,100..900&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ---------- 1. Tokens ---------- */

:root {
  /* type */
  --font-ui: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, Consolas, monospace;

  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 30px;
  --text-3xl: 38px;

  --lh-tight: 1.15;
  --lh-data: 1.3;
  --lh-ui: 1.4;
  --lh-prose: 1.5;

  --track-mono: 0.04em;
  --track-wordmark: 0.08em;

  --wdth-body: 100;
  --wdth-heading: 112;
  --wdth-wordmark: 125;
  --wdth-narrow: 90;

  /* spacing, 4px base */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  --gutter: var(--s-4);
  --row-h: 44px;          /* touch rows on phone */
  --row-h-dense: 32px;    /* desktop tables */

  /* radius */
  --r-1: 2px;
  --r-2: 4px;
  --r-3: 6px;

  /* color: dark (default) */
  --bg: #101210;
  --surface: #171a16;
  --raised: #1f231d;
  --hairline: #2b3028;
  --hairline-strong: #3b4137;
  --text: #e9e6dc;
  --text-2: #a9aa9f;
  --text-3: #84877f;
  --accent: #ff6a00;
  --accent-ink: #141008;
  --ok: #8fb57a;
  --danger: #d4674f;
  --ir: #2a2a27;

  --focus: #e9e6dc;
  --focus-offset: 2px;

  --shadow-card: 0 1px 0 var(--hairline-strong);

  color-scheme: dark;
}

:root[data-theme="paper"] {
  --bg: #efece3;
  --surface: #f7f5ee;
  --raised: #ffffff;
  --hairline: #d8d3c5;
  --hairline-strong: #b8b2a1;
  --text: #1b1a16;
  --text-2: #55544c;
  --text-3: #67655c;
  --accent: #bf4300;
  --accent-ink: #ffffff;
  --ok: #43702d;
  --danger: #b23b22;
  --ir: #2a2a27;

  --focus: #1b1a16;
  --focus-offset: 2px;

  --shadow-card: 0 1px 0 var(--hairline-strong);

  color-scheme: light;
}

@media (min-width: 1024px) {
  :root {
    --gutter: var(--s-8);
    --row-h: var(--row-h-dense);
  }
}

/* ---------- 2. Base ---------- */

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

html {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--lh-ui);
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wdth' var(--wdth-body);
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  font-variation-settings: 'wdth' var(--wdth-heading);
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { margin: 0; line-height: var(--lh-prose); }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--hairline-strong);
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--text); }

button, input, select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: var(--focus-offset);
  border-radius: var(--r-1);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

small { font-size: 0.8em; }

svg.ico {
  display: inline-block;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex: none;
  vertical-align: -3px;
}
svg.ico.moon { fill: currentColor; stroke-width: 1.25; }
svg.ico.wind { transform: rotate(calc(var(--deg, 0) * 1deg + 180deg)); }

/* ---------- 3. Text utilities ---------- */

.mono {
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  font-size: var(--text-xs);
  line-height: var(--lh-data);
}
.mono--lg { font-size: var(--text-sm); letter-spacing: 0.02em; }
.mono--xl { font-size: var(--text-md); letter-spacing: 0; }

.label {
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  font-size: var(--text-2xs);
  color: var(--text-3);
}

.wordmark {
  font-weight: 700;
  font-variation-settings: 'wdth' var(--wdth-wordmark);
  text-transform: uppercase;
  letter-spacing: var(--track-wordmark);
  font-size: var(--text-sm);
  text-decoration: none;
}

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.accent { color: var(--accent); }
.ok { color: var(--ok); }

/* ---------- 4. The info strip ---------- */

.strip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0;
  row-gap: 2px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-2xs);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  line-height: var(--lh-data);
  color: var(--text-2);
  min-width: 0;
}
@media (min-width: 1024px) {
  .strip { font-size: var(--text-xs); }
}

/* separators are drawn in the gap to the left of each field; the strip is
   shifted left by that gap and clipped, so a field that wraps to a new line
   never shows a stranded dot. */
.strip {
  margin-left: -14px;
  clip-path: inset(0 0 0 14px);
}
.strip > span {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  white-space: nowrap;
  padding-left: 14px;
}
.strip > span::before {
  content: '·';
  position: absolute;
  left: 4px;
  top: 0;
  color: var(--text-3);
}
.strip small {
  font-size: 0.82em;
  font-weight: 400;
}
.strip .ico {
  width: 12px;
  height: 12px;
  vertical-align: -2px;
  align-self: center;
}
.strip__cam { color: var(--text); }
.strip--hit .strip__cam { color: var(--accent); }
.strip__cam { flex-basis: auto; }

/* on phone the camera lands on its own line */
@media (max-width: 480px) {
  .strip__cam { flex-basis: 100%; }
}

/* ---------- 5. Primitives ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  height: 28px;
  padding: 0 var(--s-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-1);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-2xs);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip[aria-pressed="true"], .chip.is-on {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.chip--hit[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 40px;
  padding: 0 var(--s-4);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-2);
  background: transparent;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--raised); }
.btn--primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn--primary:hover { background: var(--text-2); border-color: var(--text-2); }
.btn--quiet { border-color: transparent; color: var(--text-2); }
.btn--quiet:hover { color: var(--text); }
.btn .key {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 500;
  color: inherit;
  opacity: 0.55;
  border: 1px solid currentColor;
  border-radius: var(--r-1);
  padding: 0 4px;
  line-height: 16px;
}

.hairline { border: 0; border-top: 1px solid var(--hairline); margin: 0; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-2xs);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--text-3);
  padding: var(--s-2) var(--s-2);
  border-bottom: 1px solid var(--hairline-strong);
  white-space: nowrap;
}
.table td {
  padding: 0 var(--s-2);
  height: var(--row-h);
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.table tr:hover td { background: var(--raised); }
.table .num { text-align: right; font-family: var(--font-mono); font-size: var(--text-xs); }

/* group header: a mono line sitting on a hairline */
.group-h {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-xs);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--text-2);
}
.group-h strong { color: var(--text); font-weight: 500; white-space: nowrap; }
.group-h > span:not(.count) { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-h .count { flex: none; margin-left: auto; color: var(--text-3); white-space: nowrap; }

/* alert count: the only badge, and it is orange because it is an alert */
.alert-count {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--accent);
  margin-left: 4px;
}

/* photo placeholder: an IR flash falloff. Real photos replace the background. */
.photo {
  position: relative;
  background: var(--ir) radial-gradient(ellipse at 50% 62%, #4a4a46 0%, #2b2b29 48%, #0f0f0e 100%);
  overflow: hidden;
  border-radius: var(--r-2);
}
.photo::after {
  /* faint horizontal scan texture, no gradients in UI chrome, but this is "the photo" */
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.08) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
/* a real photo replaces the placeholder: no flash gradient, no scan lines */
.photo:has(> img) { background: var(--ir); }
.photo:has(> img)::after { display: none; }
.photo > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .box {
  position: absolute;
  border: 1px dashed rgba(233,230,220,0.85);
  border-radius: 1px;
}
.photo .box .tag {
  position: absolute;
  left: -1px; top: -1px;
  transform: translateY(-100%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  font-weight: 500;
  color: #e9e6dc;
  background: rgba(16,18,16,0.85);
  padding: 1px 4px;
}
.photo { container-type: inline-size; }
.photo .burn {
  /* the camera's own burn-in, kept visible on purpose. Fields drop whole,
     camera first then temperature, instead of truncating mid-word. */
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.02em;
  color: #d9d6cc;
  background: rgba(0,0,0,0.55);
  padding: 2px 6px;
  white-space: nowrap;
  overflow: hidden;
}
.photo .burn span { flex: none; }
.photo .burn .cam { overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
@container (max-width: 250px) { .photo .burn .cam { display: none; } }
@container (max-width: 150px) { .photo .burn .temp { display: none; } }
@container (max-width: 110px) { .photo .burn .date { display: none; } }
.photo .burst {
  position: absolute; top: 6px; right: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: #e9e6dc;
  background: rgba(16,18,16,0.8);
  padding: 1px 5px;
  border-radius: var(--r-1);
}
