/* ---------- design tokens ---------- */
:root {
  --bg:           #fafaf7;
  --bg-soft:      #f3f1ec;
  --ink:          #1a1d23;
  --ink-soft:     #4b5260;
  --line:         #e3ddd0;
  --surface:      #ffffff;   /* cards, panels, tables, tiles */
  --header-bg:    rgba(250, 250, 247, 0.86);
  --on-ink:       #ffffff;   /* text/icons on top of an --ink fill */
  --on-accent:    #ffffff;   /* text on an --accent fill */
  --screen-bezel: #0c0e12;   /* LED panel — black bezel + black display, both modes */
  --accent:       #ff8a3d;
  --accent-deep:  #e26a1c;
  --teal:         #2bbfa3;
  --teal-deep:    #1f9d85;
  --radius:       14px;
  --shadow-sm:    0 1px 2px rgba(20, 24, 30, .04), 0 2px 6px rgba(20, 24, 30, .03);
  --shadow-md:    0 4px 12px rgba(20, 24, 30, .06), 0 10px 28px rgba(20, 24, 30, .05);
  --font-sans:    "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Dark theme — same tokens, retuned. Applied via data-theme on <html>, which
   a tiny no-flash <head> script sets before first paint (localStorage choice,
   else the OS prefers-color-scheme). assets/theme.js wires the header toggle. */
:root[data-theme="dark"] {
  --bg:           #121419;
  --bg-soft:      #1b1e25;
  --ink:          #f1f0ec;
  --ink-soft:     #a3abb9;
  --line:         #2c313b;
  --surface:      #1a1d24;
  --header-bg:    rgba(18, 20, 25, 0.86);
  --on-ink:       #14161a;   /* the active pill becomes light, so its text is dark */
  --on-accent:    #ffffff;
  --accent:       #db7833;   /* eased: filled buttons + minor accents */
  --accent-deep:  #d68a52;   /* eased: accent text / links / headings */
  --teal:         #34cdb0;
  --teal-deep:    #34ad95;   /* eased: eyebrow + teal text */
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .30), 0 2px 6px rgba(0, 0, 0, .25);
  --shadow-md:    0 4px 12px rgba(0, 0, 0, .40), 0 10px 28px rgba(0, 0, 0, .35);
}

/* Smooth the flip for surfaces that don't already animate these properties. */
body { transition: background-color .2s ease, color .2s ease; }
.site-header, .icon-tile, .platform-card, .feature-grid .tile,
.profile-table, .callout, .feature-strip {
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

/* Dark mode: the form-factor icons read a touch hot on the dark tiles — ease them. */
:root[data-theme="dark"] .hero-art svg { opacity: .82; }

/* The accent *text* and filled buttons are eased above (via the tokens), but the
   small in-box card icons + the colored hero lamp icons stay full strength. */
:root[data-theme="dark"] .hero-art .icon-tile:nth-child(1),
:root[data-theme="dark"] .card .icon { color: #ff9f5c; }
:root[data-theme="dark"] .hero-art .icon-tile:nth-child(3),
:root[data-theme="dark"] .card.teal .icon { color: #3fd3b6; }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent-deep); text-decoration: none; }
a:hover { color: var(--accent); }

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 .4em;
  color: var(--ink);
}
h1 { font-size: clamp(2rem, 4vw + 1rem, 3.4rem); line-height: 1.1; }
h2 { font-size: clamp(1.5rem, 1.6vw + 1rem, 2.1rem); margin-top: 0; }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1em; color: var(--ink-soft); }

/* ---------- layout ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
section    { padding: 64px 0; }
section + section { border-top: 1px solid var(--line); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; max-width: 1080px; margin: 0 auto;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-sans); font-weight: 600;
  color: var(--ink); font-size: 1.05rem;
}
.brand img {
  width: 28px; height: 28px;
  /* Apple-style squircle: ~22% corner radius + a hairline tile border and
     a soft inset shadow so the transparent PNG glyph reads as a proper icon
     tile rather than a free-floating mark next to the wordmark. Tile colors
     come from the theme tokens (--surface/--line) so the tile follows day/night
     instead of staying a white block on the dark header — the glyph itself is a
     full-colour gradient that reads on either surface. */
  border-radius: 7px;
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .6),
    0 1px 2px rgba(20, 24, 30, .08);
  background: var(--surface);
  transition: background-color .2s ease, border-color .2s ease;
}
/* The light-tuned inset highlight + drop shadow glow on a dark tile; retune to
   match the dark-mode shadow tokens (near-black, faint top sheen). */
:root[data-theme="dark"] .brand img {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .06),
    0 1px 2px rgba(0, 0, 0, .35);
}
.nav-links { display: flex; gap: 8px; }
.nav-links a {
  padding: 6px 14px; border-radius: 999px;
  color: var(--ink-soft); font-size: .95rem;
  transition: background .15s ease, color .15s ease;
}
.nav-links a:hover { background: var(--bg-soft); color: var(--ink); }
.nav-links a.active {
  background: var(--ink); color: var(--on-ink);
}

/* day/night toggle — sits at the right end of .nav-links */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-left: 4px; padding: 0;
  border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--ink-soft); cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.theme-toggle:hover { background: var(--bg-soft); color: var(--ink); }
.theme-toggle svg { width: 18px; height: 18px; }
/* moon when light (click → dark), sun when dark (click → light) */
.theme-toggle .icon-sun  { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }

/* ---------- hero ---------- */
.hero {
  padding: 96px 0 80px;
  background:
    radial-gradient(1200px 360px at 80% -10%, rgba(255, 138, 61, .14), transparent 60%),
    radial-gradient(900px 320px at -10% 110%, rgba(43, 191, 163, .10), transparent 60%);
}
.hero-inner { display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; align-items: center; }
.hero h1 .accent { color: var(--accent-deep); }
.hero p.lead { font-size: 1.15rem; max-width: 38ch; color: var(--ink-soft); }
.hero-art {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  align-items: center; justify-items: center;
  color: var(--ink);
}
.hero-art .icon-tile {
  width: 100%; aspect-ratio: 1; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: grid; place-items: center;
}
/* tower · cube · wall · strip — gentle arch, two centre tiles lifted */
.hero-art .icon-tile:nth-child(1) { color: var(--accent-deep); }
.hero-art .icon-tile:nth-child(2) { color: var(--ink);       transform: translateY(-10px); }
.hero-art .icon-tile:nth-child(3) { color: var(--teal-deep); transform: translateY(-10px); }
.hero-art .icon-tile:nth-child(4) { color: var(--ink); }
.hero-art svg { width: 100%; height: 100%; }

@media (max-width: 760px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero { padding: 64px 0 56px; }
  .hero-art { grid-template-columns: repeat(2, 1fr); }
  .hero-art .icon-tile:nth-child(2),
  .hero-art .icon-tile:nth-child(3) { transform: none; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px;
  font-family: var(--font-sans); font-weight: 500; font-size: .95rem;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .08s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-deep); color: var(--on-accent); transform: translateY(-1px); }
.btn-ghost {
  background: transparent; color: var(--ink); border-color: var(--line);
}
.btn-ghost:hover { background: var(--bg-soft); }
.btn[disabled], .btn.coming-soon {
  cursor: not-allowed; opacity: .68;
  background: var(--bg-soft); color: var(--ink-soft); border-color: var(--line);
}
.btn.coming-soon::after { content: "·  soon"; margin-left: 2px; font-size: .8em; }
/* square icon-only button (e.g. GitHub link next to a text button) */
.btn-icon { padding: 0; width: 42px; height: 42px; justify-content: center; }
.btn-icon svg { width: 20px; height: 20px; fill: currentColor; }
/* ESP Web Tools fallback for browsers without WebSerial (Firefox/Safari) */
.btn.flash-unsupported { cursor: not-allowed; opacity: .68; color: var(--ink-soft); }

.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- card grid ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card h3 { margin-bottom: .35em; }
.card .icon {
  width: 36px; height: 36px; margin-bottom: 14px;
  color: var(--accent-deep);
}
.card.teal .icon { color: var(--teal-deep); }
.card p { margin-bottom: 0; font-size: .95rem; }

/* feature grid - tighter */
.feature-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.feature-grid .tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.feature-grid .tile strong {
  font-family: var(--font-sans); font-weight: 600; color: var(--ink);
  display: block; margin-bottom: 4px;
}
.feature-grid .tile span { font-size: .9rem; color: var(--ink-soft); }

/* ---------- platform cards (apps page) ---------- */
.platforms { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.platform-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 14px;
}
.platform-card .screenshot {
  aspect-ratio: 16/10; border: 1.5px dashed var(--line); border-radius: 10px;
  background: var(--bg-soft); color: var(--ink-soft);
  display: grid; place-items: center;
  font-family: var(--font-sans); font-size: .85rem; letter-spacing: .04em;
}
/* placeholder "display": the platform logo rendered on a 16x16 LED matrix */
.platform-card .screen {
  aspect-ratio: 16/10; border-radius: 10px;
  background: var(--screen-bezel); border: 1px solid var(--line);
  display: grid; place-items: center; padding: 7%;
  overflow: hidden;
}
.platform-card .screen svg {
  height: 100%; width: auto; max-width: 100%; aspect-ratio: 1;
  background: #0c0e12; border-radius: 3px;   /* the 16x16 display stays black */
}
.screen-apple   { color: #d8d8de; }
.screen-android { color: #3ddc84; }
.screen-linux   { color: #ededed; }
.screen-homebridge    { color: #b58cf0; }
.screen-homeassistant { color: #38c4f8; }

.platform-card h3 { margin: 0; }
.platform-card p  { margin: 0; font-size: .95rem; }
.platform-card .btn { align-self: flex-start; }
.platform-card .card-actions { display: flex; gap: 10px; align-items: center; }

/* shared feature strip */
.feature-strip {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  padding: 18px 22px; margin-bottom: 28px;
  background: linear-gradient(90deg, rgba(255, 138, 61, .08), rgba(43, 191, 163, .08));
  border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--font-sans); font-size: .92rem; color: var(--ink);
}
.feature-strip span { white-space: nowrap; }
.feature-strip span + span::before { content: "·"; margin-right: 14px; color: var(--ink-soft); }

/* ---------- tables ---------- */
.profile-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.profile-table th, .profile-table td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: .95rem;
}
.profile-table th {
  background: var(--bg-soft); font-family: var(--font-sans); font-weight: 600;
}
.profile-table tr:last-child td { border-bottom: none; }
.dl-stack { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.dl-link { padding: 6px 12px; font-size: .85rem; }
.profile-table code {
  font-size: .85rem; color: var(--accent-deep);
  background: rgba(255, 138, 61, .08); padding: 2px 6px; border-radius: 4px;
}

/* ---------- callout ---------- */
.callout {
  background: var(--surface); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 16px 20px; margin-top: 24px;
  box-shadow: var(--shadow-sm);
}
.callout strong { font-family: var(--font-sans); color: var(--ink); }
.callout code {
  font-size: .85rem; background: var(--bg-soft);
  padding: 2px 6px; border-radius: 4px;
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: .9rem;
}
.site-footer a { color: var(--ink); border-bottom: 1px dotted var(--ink-soft); }
.site-footer a:hover { color: var(--accent-deep); border-bottom-color: var(--accent); }

/* ---------- small utility ---------- */
.eyebrow {
  display: inline-block;
  font-family: var(--font-sans); font-weight: 500;
  font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--teal-deep);
  margin-bottom: 12px;
}
.section-head { max-width: 56ch; margin-bottom: 36px; }
.section-head p { font-size: 1.05rem; }
