/* ============================================================
   TruTech — tokens
   Neomorphism needs opaque, pre-mixed shadow tints per brightness
   (not alpha-blended black/white) or the shadows read flat instead
   of tactile — same technique as tru_theme.dart's Tru.raised()/
   Tru.pressed(), translated to CSS box-shadow pairs.

   Dark is the default regardless of system preference — [data-theme
   ="light"] is the only thing that switches it, set by the toggle
   (persisted) or the inline pre-paint script in <head> reading that
   same saved choice, so there's no flash of the wrong theme.
   ============================================================ */
:root {
  --ground: #151328;
  --shadow-lo: #0A0917;
  --shadow-hi: #262444;
  --text: #F2F1FB;
  --muted: #ADABC9;
  --faint: #78769A;
  --accent: #6366F1;
  --radius: 20px;
  --radius-lg: 28px;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Fluid base size — scales gently between phones and desktops;
     the >=1920px rule further up further below covers TVs/4K. */
  font-size: clamp(15px, 0.85vw + 11px, 17px);
}

:root[data-theme="light"] {
  --ground: #ECEBFB;
  --shadow-lo: #C3C1E8;
  --shadow-hi: #FFFFFF;
  --text: #1B1B2F;
  --muted: #55536E;
  --faint: #83809F;
  --accent: #4F46E5;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.02em; margin: 0 0 0.5em; }
p { margin: 0 0 1em; color: var(--muted); }
img { max-width: 100%; display: block; }

/* ============================================================
   Neomorphic primitive
   ============================================================ */
.neo {
  background: var(--ground);
  border-radius: var(--radius);
  box-shadow:
    9px 9px 20px var(--shadow-lo),
    -9px -9px 20px var(--shadow-hi);
  transition: box-shadow 180ms ease, transform 180ms ease;
}

.neo-pressed,
.neo:active {
  box-shadow:
    inset 5px 5px 12px var(--shadow-lo),
    inset -5px -5px 12px var(--shadow-hi);
}

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border: none;
  cursor: pointer;
  color: var(--text);
}
.icon-btn:hover { transform: translateY(-2px); }
#icon-moon { display: block; }
#icon-sun { display: none; }
[data-theme="light"] #icon-sun { display: block; }
[data-theme="light"] #icon-moon { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 26px;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text);
}
.btn:hover { transform: translateY(-3px); }
.btn-primary {
  background: linear-gradient(135deg, #7C7AF5, #4F46E5);
  color: #fff;
  box-shadow: 9px 9px 22px var(--shadow-lo), -9px -9px 22px var(--shadow-hi), 0 8px 24px -8px rgba(99,102,241,0.7);
}

/* ============================================================
   Background field — ambient, always-on glow behind everything
   ============================================================ */
.bg-field {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
}
.blob-a { width: 40vw; height: 40vw; top: -10vw; left: -10vw; background: #6366F1; }
.blob-b { width: 34vw; height: 34vw; bottom: -12vw; right: -8vw; background: #F97316; opacity: 0.16; }
.blob-c { width: 28vw; height: 28vw; top: 40vh; right: 20vw; background: #00D4FF; opacity: 0.12; }

/* ============================================================
   Nav
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 5vw, 64px);
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--ground) 78%, transparent);
}
.wordmark { display: flex; align-items: baseline; gap: 2px; font-size: 1.25rem; flex: none; }
.bracket { font-family: var(--font-mono); font-weight: 700; color: var(--accent); letter-spacing: 1px; }
.suffix { font-family: var(--font-body); font-weight: 800; letter-spacing: 1px; }
.nav-links { display: flex; gap: 28px; font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.nav-links a:hover { color: var(--accent); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }

/* ============================================================
   Mobile menu — off-canvas drawer under the nav-links breakpoint
   ============================================================ */
.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 19;
  height: 100dvh;
  width: min(78vw, 320px);
  padding: 96px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: var(--ground);
  box-shadow: -12px 0 30px var(--shadow-lo);
  transform: translateX(100%);
  transition: transform 220ms ease;
}
.mobile-menu.open { transform: translateX(0); }
.mobile-menu a {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.mobile-menu a:hover { color: var(--accent); }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative;
  min-height: min(88vh, 820px);
  display: flex;
  align-items: center;
  padding: 40px clamp(16px, 5vw, 64px) 80px;
  overflow: hidden;
}
.hero-visual {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
  z-index: -2;
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}

/* Keeps hero text legible over the busy, brightly-lit generated image
   regardless of which part of it sits behind the copy. */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    100deg,
    var(--ground) 0%,
    color-mix(in srgb, var(--ground) 88%, transparent) 32%,
    color-mix(in srgb, var(--ground) 35%, transparent) 58%,
    transparent 78%
  );
}
.hero-content { max-width: 760px; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--card-accent, var(--accent));
  margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(2.1rem, 5.2vw + 1rem, 4.4rem);
  line-height: 1.05;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.lede { font-size: 1.1rem; max-width: 60ch; }
.hero-actions { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 28px; }

/* ============================================================
   Sections
   ============================================================ */
.section {
  padding: clamp(50px, 9vw, 90px) clamp(16px, 5vw, 64px);
  max-width: 1180px;
  margin: 0 auto;
}
.section-head { margin-bottom: 40px; }
.section-head h2, .panel h2 { font-size: clamp(1.7rem, 3vw + 1rem, 2.6rem); }
.panel { padding: clamp(24px, 5vw, 56px); }
.prose { max-width: 72ch; font-size: 1.03rem; }
.prose strong { color: var(--text); }

.build-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 28px;
  margin-top: 32px;
}
.build-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--ground));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}
.build-item h3 { font-size: 1.06rem; margin-bottom: 8px; }
.build-item p { font-size: 0.92rem; margin: 0; }

.contact-panel { text-align: center; }
.contact-panel .lede { margin: 0 auto 24px; }

/* ============================================================
   Apps grid
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 26px;
}
.card {
  display: flex;
  flex-direction: column;
  padding: 26px;
  cursor: pointer;
}
.card:hover { transform: translateY(-6px); }
.card-more {
  margin-top: auto;
  padding-top: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--card-accent, var(--accent));
}
.card-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 18px;
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 14%, var(--ground));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--card-accent, var(--accent)) 25%, transparent);
  transition: box-shadow 180ms ease;
}
.card-icon img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .card-icon {
  box-shadow: 0 0 24px -4px var(--card-accent, var(--accent));
}
.card-tagline {
  font-weight: 700;
  font-size: 1.06rem;
  margin-bottom: 8px;
  color: var(--text);
}
.card-desc { font-size: 0.92rem; margin-bottom: 16px; }
.card-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  /* Dark theme: the raw accent as text reads fine against a near-black
     tinted background. Light theme needs its own darker shade here (see
     the [data-theme="light"] override below) — a bright accent as text on
     a pale same-hue tint is a near-isoluminant pairing that's genuinely
     hard to read, not just low-contrast-by-the-numbers. */
  color: var(--card-accent, var(--accent));
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 14%, transparent);
}
.tag.tag-dev {
  color: #fff;
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 65%, transparent);
}
/* Same fix, same reason, for every other place a per-app accent is used
   as text color directly (not just background-tinted pills): the eyebrow
   labels and "Learn more" links. Checkmarks/icons are left alone — shape
   recognition tolerates lower contrast far better than reading text does. */
:root[data-theme="light"] .tag:not(.tag-dev),
:root[data-theme="light"] .eyebrow,
:root[data-theme="light"] .card-more {
  color: color-mix(in srgb, var(--card-accent, var(--accent)) 55%, black);
}

/* ============================================================
   Services
   ============================================================ */
.services-grid { margin-top: 8px; }
.services-grid .card { cursor: default; }
.service-icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  color: var(--card-accent, var(--accent));
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 14%, var(--ground));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--card-accent, var(--accent)) 25%, transparent);
}
.services-note {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  font-size: 1rem;
  color: var(--text);
  max-width: 62ch;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  padding: 48px 20px 60px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--faint);
  font-size: 0.85rem;
  text-align: center;
}
.footer-top {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.footer-note { color: var(--faint); }
.footer-sitemap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
}
.footer-sitemap a { color: var(--muted); font-weight: 600; }
.footer-sitemap a:hover { color: var(--accent); }

/* ============================================================
   App detail pages (apps/*.html)
   ============================================================ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 28px;
}
.back-link:hover { color: var(--accent); }

.detail-hero {
  padding: 48px clamp(16px, 5vw, 64px) 20px;
  max-width: 1180px;
  margin: 0 auto;
}
.detail-head {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.detail-icon {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  overflow: hidden;
  flex: none;
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 16%, var(--ground));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--card-accent, var(--accent)) 28%, transparent), 0 0 32px -8px var(--card-accent, var(--accent));
}
.detail-icon img { width: 100%; height: 100%; object-fit: cover; }
.detail-titles .eyebrow { margin-bottom: 6px; }
.detail-titles h1,
.detail-hero > h1 {
  font-size: clamp(1.8rem, 3.4vw + 1rem, 2.9rem);
  line-height: 1.08;
  margin-bottom: 0.4em;
}
.detail-titles h1 { margin-bottom: 0; }
.detail-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.detail-problem { font-size: 1.05rem; max-width: 68ch; }

.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}
.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--text);
  font-size: 0.98rem;
}
.feature-list svg {
  flex: none;
  margin-top: 3px;
  color: var(--card-accent, var(--accent));
}

.stack-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.stack-chip {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 10%, var(--ground));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--card-accent, var(--accent)) 20%, transparent);
}

.detail-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.detail-nav-link {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-nav-link.next { text-align: right; align-items: flex-end; }
.detail-nav-link:hover { transform: translateY(-4px); }
.detail-nav-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.detail-nav-name { font-weight: 700; color: var(--text); }
.detail-nav-empty { visibility: hidden; }
@media (max-width: 560px) {
  .detail-nav { grid-template-columns: 1fr; }
  .detail-nav-link.next { text-align: left; align-items: flex-start; }
}

/* ============================================================
   Reveal-on-scroll
   Visible by default (the safe fallback for no-JS, a blocked
   IntersectionObserver, or a crawler/screenshot tool that never
   scrolls). assets/site.js adds `.js-reveal` to <html> only after it
   has confirmed it can actually deliver the animation, and that's
   the only thing that switches these elements to their hidden
   starting state.
   ============================================================ */
.js-reveal .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 700ms ease, transform 700ms ease;
}
.js-reveal .reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   Responsive — phones, foldables, tablets, laptops, TVs

   The fluid clamp()/vw sizing above already carries most of the
   weight; these breakpoints handle the things clamp() can't:
   layout shape changes (nav → drawer, grid columns collapsing to
   one), and safety floors/ceilings clamp() alone doesn't cover.
   ============================================================ */

/* Small phones and folded/cover-screen foldables (Z Flip cover
   ≈260-320px, small Android ≈360px) — force single-column grids so
   `minmax(280px, 1fr)` can never overflow a viewport narrower than
   its own minimum. */
@media (max-width: 400px) {
  .grid, .build-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: clamp(1.7rem, 9vw, 2.4rem); }
}

/* Below this, the full inline link row doesn't fit — switch to the
   hamburger + off-canvas drawer instead of just hiding navigation
   with no replacement. */
@media (max-width: 760px) {
  .nav-links { display: none; }
  .menu-btn { display: grid; }
}

/* The desktop spacing scale is deliberately generous; on a phone that
   same generosity just turns into a lot of scrolling for one hero and
   eight cards. Tighten section rhythm and card gaps here without
   touching the wider breakpoints. */
@media (max-width: 640px) {
  .hero { min-height: 0; padding-top: 32px; padding-bottom: 48px; }
  .section { padding-top: 40px; padding-bottom: 40px; }
  .section-head { margin-bottom: 24px; }
  .grid, .build-grid { gap: 16px; }
  .panel { padding: 22px; }
  .card { padding: 20px; }
}
@media (min-width: 761px) {
  .mobile-menu { display: none; }
}

/* Short viewports — landscape phones, and a folded/cover-screen
   foldable held sideways — a fixed 88vh hero would either overflow
   or crush the content, so drop the min-height and let it size to
   content instead. */
@media (max-height: 480px) and (orientation: landscape) {
  .hero { min-height: 0; padding-top: 96px; padding-bottom: 48px; }
}

/* Foldables unfolded / small tablets (Fold ≈717px, Duo ≈540px per
   pane, small iPad ≈768px) — apps grid settles at 2 columns instead
   of the auto-fit minimum producing an awkward single wide column. */
@media (min-width: 600px) and (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* Laptops and desktops — nothing structural changes here, the fluid
   tokens already carry it; this just widens the ceiling slightly so
   content doesn't feel cramped against the 1180px section cap on a
   1440px+ display. */
@media (min-width: 1440px) {
  .section { max-width: 1280px; }
}

/* TVs / very large or 4K displays, typically viewed from further
   away — scale the base unit up so text and spacing don't shrink
   into a small island in the middle of the screen. */
@media (min-width: 1920px) {
  :root { font-size: 19px; }
  .section, .nav { max-width: 1500px; margin-left: auto; margin-right: auto; }
  .nav { max-width: none; }
}
@media (min-width: 2600px) {
  :root { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .btn:hover, .card:hover, .icon-btn:hover { transform: none; }
  html { scroll-behavior: auto; }
}
