/*
 * DiThiKai — component styles on top of tokens.css.
 * Lifted from the phase 2 wireframe (brand/explorations/wireframe/wireframe.css).
 * Spec and rationale: docs/design.md, decisions D-37 to D-40.
 */

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  /* anchor targets and focused elements stay below the sticky header (WCAG 2.4.11);
     defined here, not on body, because scroll-padding-top is read on html */
  --header-offset: 3rem;              /* mobile: only the nav row is sticky (48 px) */
  scroll-padding-top: var(--header-offset);
}
@media (min-width: 40rem) { html { --header-offset: 4.75rem; } }  /* whole header, one row (75 px) */
body {
  margin: 0;
  /* header · main · footer; main grows so the footer sits at the bottom of short pages */
  display: grid; grid-template-rows: auto 1fr auto; min-height: 100vh; min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading-body);
}
img, svg { display: block; max-width: 100%; }
p, ul, ol { margin: 0 0 var(--space-s); }
p, li { hyphens: auto; }
h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: var(--weight-heading);
  line-height: var(--leading-heading);
  margin: 0;
  overflow-wrap: break-word;
  text-wrap: balance;
}
h1 { font-size: var(--step-4); margin-bottom: 0.5em; }
h2 { font-size: var(--step-2); margin-bottom: 0.8em; }
h3 { font-size: var(--step-1); margin-bottom: 0.3em; }
a { color: var(--color-link); text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
:focus-visible { outline: var(--focus-width) solid var(--color-focus); outline-offset: var(--focus-offset); border-radius: 2px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.wrap { width: 100%; max-width: var(--width-content); margin-inline: auto; padding-inline: var(--space-gutter); }
.section { padding-block: var(--space-section); }
.section--tint { background: var(--color-surface-tint); }
.prose { max-width: var(--measure); }
.muted { color: var(--color-text-muted); }

/* Skip link */
.skip-link {
  position: absolute; left: var(--space-s); top: -10rem; z-index: 100;
  background: var(--color-bg); padding: var(--space-xs) var(--space-s); border-radius: var(--radius-s);
}
.skip-link:focus { top: var(--space-s); }

/* Header — whole header sticky; on narrow screens the logo row scrolls away
   (negative top = height of the logo row), only the nav row stays */
.site-header {
  --brand-row: 4.9rem;                /* padding-top 1rem + logo 3.4rem + row gap 0.5rem */
  position: sticky; top: 0; z-index: 10;
  background: var(--color-header);
  backdrop-filter: blur(8px);
  border-bottom: var(--border-width) solid var(--color-border);
}
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem var(--space-m); padding-block: 1rem 0.25rem;
}
.brand img { height: 3.4rem; width: auto; }
.site-nav ul { display: flex; flex-wrap: wrap; gap: 0 var(--space-m); list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding-block: 0.6rem;
  font-family: var(--font-heading); font-weight: var(--weight-heading); font-size: 0.9375rem;
  color: var(--color-text); text-decoration: none;
}
.site-nav a:hover { color: var(--color-link); }
.site-nav a[hreflang] { color: var(--color-link); }
@media (max-width: 39.99rem) {
  .site-header { top: calc(-1 * var(--brand-row)); }
  .site-nav { flex-basis: 100%; }
  .site-nav ul { justify-content: space-between; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; min-height: var(--target-min);
  padding: 0.55em 1.2em; border-radius: var(--radius-s);
  font-family: var(--font-heading); font-weight: var(--weight-heading); font-size: 0.9375em;
  text-decoration: none; background: var(--color-link); color: var(--color-on-link);
}
.btn--secondary { background: none; color: var(--color-link); box-shadow: inset 0 0 0 1.5px var(--color-link); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

/* Hero */
.hero .wrap { display: grid; gap: var(--space-l); align-items: center; }
.lead { font-size: 1.125em; color: var(--color-text-muted); max-width: 34em; margin-bottom: var(--space-m); }
.hero-art { display: none; position: relative; }
@media (min-width: 48rem) {
  .hero .wrap { grid-template-columns: 1.35fr 1fr; }
  .hero-art { display: block; }
}

/* Hero h1 = name figure (D-39): wordmark + legend + claim */
.hero-name { margin: 0; max-width: 34rem; }
.hero-name img { width: 100%; height: auto; }
.hero-legend {
  /* columns follow the glyph extents of the wordmark: DiThi · gap · Kai */
  display: grid; grid-template-columns: 561fr 52fr 332.5fr; max-width: 34rem; margin: 0.7rem 0 var(--space-l);
  font-size: 0.875rem; line-height: 1.3; color: var(--color-text-muted); text-align: center;
}
.hero-legend > span { padding-top: 0.4em; border-top: 2px solid var(--color-text); }
.hero-legend > span + span { grid-column: 3; border-image: var(--gradient-brand) 1; border-top-width: 2px; border-top-style: solid; }
.claim {
  font-family: var(--font-heading); font-weight: var(--weight-heading);
  font-size: var(--step-2); line-height: var(--leading-heading); margin-bottom: var(--space-xs);
}

/* Circuit motif: draws in once, then signals travel to the rings (M4).
   The glowing node is the pause switch (P3, WCAG 2.2.2), CSS only. */
.motif { width: 100%; height: auto; overflow: visible; }
.motif .grad-top { stop-color: var(--color-brand-cyan); }
.motif .grad-bottom { stop-color: var(--color-brand-blue); }
.motif .trace { fill: none; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw 1.6s cubic-bezier(.6, 0, .3, 1) forwards; }
.motif .trace:nth-child(2) { animation-delay: .15s; }
.motif .trace:nth-child(3) { animation-delay: .3s; }
.motif .trace:nth-child(n+4) { animation-delay: .45s; opacity: .45; }
.motif .ring { fill: var(--color-bg); stroke-width: 4; opacity: 0; animation: fade .3s 1.6s forwards; }
.motif .glow { opacity: 0; animation: glow-in .6s 1.8s forwards; }
.motif .node { fill: #8fdcff; stroke: var(--color-brand-cyan); stroke-width: 4; opacity: 0; animation: fade .3s 1.6s forwards; }
.motif .signal { fill: none; stroke: var(--color-brand-cyan); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 4 96; stroke-dashoffset: 100; opacity: 0; animation: fade .2s 2s forwards, travel 5s 2s linear infinite; }
.motif .signal:nth-child(2) { animation-delay: 2.9s, 2.9s; animation-duration: .2s, 6s; }
.motif .signal:nth-child(3) { animation-delay: 2.4s, 2.4s; animation-duration: .2s, 4.5s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }
@keyframes glow-in { to { opacity: .55; } }
@keyframes travel { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }

.motif-pause:checked ~ .motif .signal { animation-play-state: paused; }
.node-switch {
  position: absolute; left: 62.5%; top: 50%; translate: -50% -50%;
  width: 3.2rem; height: 3.2rem; border-radius: 50%; cursor: pointer;
}
.node-switch:hover { box-shadow: 0 0 0 2px var(--color-brand-cyan); }
.motif-pause:focus-visible ~ .node-switch { outline: var(--focus-width) solid var(--color-focus); outline-offset: var(--focus-offset); }
.node-tip {
  position: absolute; left: 50%; top: 100%; translate: -50% 0.4rem;
  font-size: 0.75rem; white-space: nowrap; pointer-events: none;
  background: var(--color-text); color: var(--color-bg); padding: 0.15em 0.6em; border-radius: 4px;
  opacity: 0; transition: opacity .2s;
}
.node-switch:hover .node-tip, .motif-pause:focus-visible ~ .node-switch .node-tip { opacity: 1; }
.node-tip .on, .motif-pause:checked ~ .node-switch .node-tip .off { display: none; }
.motif-pause:checked ~ .node-switch .node-tip .on { display: inline; }

@media (prefers-reduced-motion: reduce) {
  .motif * { animation: none !important; }
  .motif .trace { stroke-dashoffset: 0; }
  .motif .ring, .motif .node { opacity: 1; }
  .motif .glow { opacity: .55; }
  .motif .signal, .node-switch, .motif-pause { display: none; }
}

/* Apps (K3: stage for released apps, compact list for coming soon) */
.app-list {
  display: grid; gap: var(--space-s); list-style: none; margin: 0; padding: 0;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}
.app {
  background: var(--color-surface-tile); border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-l); padding: var(--space-m);
}
.app-icon { border-radius: 22.5%; }
.app--released {
  grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr;
  gap: var(--space-2xs) var(--space-m); align-items: start; padding: clamp(1.2rem, 3vw, 1.8rem);
}
.app--released .app-icon { width: 7.5rem; height: 7.5rem; grid-row: 1 / span 5; }
.app--released h3 { font-size: var(--step-2); }
.app--released h3 a { color: inherit; text-decoration: none; }
.app--released h3 a:hover { text-decoration: underline; }
.app-text { margin: 0; max-width: var(--measure); }
.app-platforms { margin: 0; font-size: 0.8125em; color: var(--color-text-muted); }
.app-status { margin-top: var(--space-xs); }
.app-more { font-size: 0.9375em; font-weight: 500; margin-top: var(--space-xs); justify-self: start; }
.app--soon {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 var(--space-s);
  border-style: dashed; background: transparent;
}
.app--soon .app-icon { width: 3rem; height: 3rem; grid-row: 1 / span 2; background: var(--color-border); opacity: .6; }
.app--soon h3 { color: var(--color-text-muted); margin: 0; }
.pill {
  justify-self: start; border: var(--border-width) solid var(--color-border); border-radius: var(--radius-pill);
  padding: 0 0.75em; font-size: 0.78em; color: var(--color-text-muted);
}
@media (max-width: 30rem) {
  .app--released { grid-template-columns: 1fr; }
  .app--released .app-icon { width: 5rem; height: 5rem; grid-row: auto; margin-bottom: var(--space-xs); }
}

/* Store badges (D-12): official artwork, unaltered, visible height 40 px,
   clear space ≥ ¼ of the height, App Store first. Only for stores where the app is live. */
.store-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; list-style: none; margin: var(--space-xs) 0 0; padding: 0; }
.store-badges a { display: block; }
.store-badges img { height: 40px; width: auto; }
/* The Google Play PNGs carry transparent padding that differs between de and en:
   scale them so the visible badge is 40 px high and cancel the vertical padding.
   The horizontal padding stays and adds to the clear space. */
.store-badges .badge-gplay-de { height: 52.08px; margin-block: -6.04px; }
.store-badges .badge-gplay-en { height: 59.52px; margin-block: -9.76px; }

/* About (A3: first-person paragraph + principles) */
.about-grid { display: grid; gap: var(--space-xl); }
@media (min-width: 48rem) { .about-grid { grid-template-columns: 1fr 1fr; gap: var(--space-2xl); align-items: center; } }
.about-grid p:last-child { margin-bottom: 0; }
.principles { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-m); }
.principles li { display: grid; grid-template-columns: 2rem 1fr; gap: 0.15em var(--space-s); }
.principles svg { grid-row: 1 / span 2; width: 2rem; height: 2rem; fill: none; stroke: var(--color-link); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.principles strong { font-weight: 600; }
.principles span { grid-column: 2; color: var(--color-text-muted); font-size: 0.9375em; }

/* Contact */
.contact-mail { font-family: var(--font-heading); font-weight: var(--weight-heading); font-size: var(--step-1); }

/* Footer */
.site-footer { background: var(--color-surface-tint); border-top: var(--border-width) solid var(--color-border); padding-block: var(--space-m); font-size: 0.875em; color: var(--color-text-muted); }
.site-footer ul { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-m); list-style: none; margin: 0; padding: 0; }
.site-footer a { color: var(--color-text-muted); display: inline-block; padding-block: 0.3rem; }

/* Legal pages (L1) */
.legal { padding-block: var(--space-section); }
.legal .stand { color: var(--color-text-muted); font-size: 0.875em; margin-bottom: var(--space-l); }
.legal h2 { font-size: var(--step-1); margin: 2em 0 0.5em; }

/* 404 */
.not-found { padding-block: var(--space-section); }
.not-found .code {
  font-family: var(--font-heading); font-weight: var(--weight-heading);
  font-size: clamp(4rem, 2rem + 9vw, 8rem); line-height: 1; letter-spacing: .04em; margin: 0 0 0.15em;
  background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.not-found .en { border-top: var(--border-width) solid var(--color-border); padding-top: var(--space-s); margin-top: var(--space-l); color: var(--color-text-muted); max-width: var(--measure); }

/* Print: black on white, no navigation or motion, URLs after external links */
@media print {
  :root {
    --color-bg: #fff; --color-text: #000; --color-text-muted: #333; --color-link: #000;
    --color-border: #999; --color-surface-tint: #fff; --color-surface-tile: #fff; --color-header: #fff;
  }
  body { font-size: 11pt; }
  .skip-link, .site-nav, .hero-art, .btn, .btn-row, .app-more { display: none; }
  .site-header { position: static; backdrop-filter: none; }
  /* <picture> keeps the dark source when printing from dark mode: force the light files */
  .brand img { content: url("../img/logo.svg"); }
  .hero-name img { content: url("../img/wordmark.svg"); }
  .section, .legal, .not-found { padding-block: 1.5rem; }
  main a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; overflow-wrap: anywhere; }
  .store-badges a::after { content: none; }
  h2, h3 { break-after: avoid; }
  .app, .principles li { break-inside: avoid; }
}
