/* ==========================================================================
   TinyLab360 design system
   Tokens -> base -> layout -> components. Tool pages may add their own CSS
   for the tool area but should reuse tokens and components where possible.
   No web fonts on purpose: system fonts are fast and leak no data to third parties.
   ========================================================================== */

:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  --c-bg: #ffffff;
  --c-surface: #f6f7fb;
  --c-surface-2: #eceef6;
  --c-border: #dcdfea;
  --c-text: #161a2b;
  --c-text-muted: #5a6078;
  --c-primary: #4f46e5;
  --c-primary-hover: #4338ca;
  --c-primary-contrast: #ffffff;
  --c-accent: #0891b2;
  --c-success: #047857;
  --c-success-bg: #d1fae5;
  --c-warning: #92400e;
  --c-warning-bg: #fef3c7;
  --c-danger: #b91c1c;
  --c-focus: #f59e0b;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 12px rgb(16 24 40 / 6%);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;

  --container: 72rem;
  --gutter: 1rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #0f1220;
    --c-surface: #171b2e;
    --c-surface-2: #20253c;
    --c-border: #2e3450;
    --c-text: #e8eaf4;
    --c-text-muted: #a2a8c3;
    --c-primary: #818cf8;
    --c-primary-hover: #a5b4fc;
    --c-primary-contrast: #0f1220;
    --c-accent: #22d3ee;
    --c-success: #6ee7b7;
    --c-success-bg: #06372a;
    --c-warning: #fcd34d;
    --c-warning-bg: #3b2a06;
    --c-danger: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 12px rgb(0 0 0 / 25%);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--c-primary); text-underline-offset: 2px; }
a:hover { color: var(--c-primary-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-4); }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 var(--space-4); }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.92em; }
kbd {
  padding: 0.05em 0.4em;
  border: 1px solid var(--c-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--c-surface);
}
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; padding: var(--space-2) var(--space-4); background: var(--c-primary); color: var(--c-primary-contrast); }
.skip-link:focus { left: var(--space-2); top: var(--space-2); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.site-main { flex: 1; }
.section { padding-block: var(--space-8); }

.site-header { border-bottom: 1px solid var(--c-border); background: var(--c-bg); }
.site-header__inner { display: flex; align-items: center; gap: var(--space-6); min-height: 3.5rem; }
.logo { display: inline-flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--c-text); font-size: 1.15rem; }
.logo strong { color: var(--c-primary); }
.site-nav { flex: 1; }
.site-nav__link { color: var(--c-text-muted); text-decoration: none; font-weight: 500; }
.site-nav__link:hover { color: var(--c-text); }
.lang-switch { display: flex; gap: var(--space-1); }
.lang-switch__link { padding: 0.2rem 0.45rem; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; color: var(--c-text-muted); text-decoration: none; }
.lang-switch__link:hover { background: var(--c-surface); color: var(--c-text); }
.lang-switch__link.is-active { background: var(--c-surface-2); color: var(--c-text); }

.site-footer { margin-top: var(--space-12); border-top: 1px solid var(--c-border); background: var(--c-surface); font-size: 0.9rem; color: var(--c-text-muted); }
.site-footer__inner { display: grid; gap: var(--space-4); padding-block: var(--space-8); }
.site-footer__about { max-width: 40rem; margin: 0; }
.site-footer a { color: var(--c-text-muted); }
.site-footer a:hover { color: var(--c-text); }
.site-footer__links, .site-footer__legal { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--c-surface-2);
  --btn-fg: var(--c-text);
  --btn-border: var(--c-border);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 2.5rem; padding: 0.45rem 0.95rem;
  font: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-border); border-radius: var(--radius);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { --btn-bg: var(--c-border); color: var(--btn-fg); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn--primary { --btn-bg: var(--c-primary); --btn-fg: var(--c-primary-contrast); --btn-border: var(--c-primary); }
.btn--primary:hover { --btn-bg: var(--c-primary-hover); --btn-border: var(--c-primary-hover); }
.btn--secondary { --btn-bg: var(--c-bg); }
.btn--secondary:hover { --btn-bg: var(--c-surface); }
.btn--ghost { --btn-bg: transparent; --btn-border: transparent; }
.btn--ghost:hover { --btn-bg: var(--c-surface-2); }
.btn--sm { min-height: 2rem; padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn--lg { min-height: 3rem; padding: 0.7rem 1.3rem; font-size: 1.05rem; }
.btn--icon { padding-inline: 0.55rem; }
.btn[aria-pressed='true'] { --btn-bg: var(--c-primary); --btn-fg: var(--c-primary-contrast); --btn-border: var(--c-primary); }

.btn-group { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); }

/* ---------- Badges ---------- */
.badges { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.7rem; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; line-height: 1.3;
  background: var(--c-surface-2); color: var(--c-text);
}
.badge--local { background: var(--c-success-bg); color: var(--c-success); }
.badge--offline { background: var(--c-surface-2); color: var(--c-accent); }
.badge--server { background: var(--c-warning-bg); color: var(--c-warning); }

/* ---------- Cards ---------- */
.card { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow); }

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--space-1); }
.label { font-size: 0.85rem; font-weight: 600; color: var(--c-text-muted); }
.input, .select {
  min-height: 2.5rem; padding: 0.4rem 0.7rem; font: inherit;
  color: var(--c-text); background: var(--c-bg);
  border: 1px solid var(--c-border); border-radius: var(--radius);
}
input[type='range'] { accent-color: var(--c-primary); }
input[type='color'] { width: 2.5rem; height: 2.5rem; padding: 2px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-bg); cursor: pointer; }

/* ---------- Home ---------- */
.home-hero { padding-block: var(--space-12) var(--space-6); max-width: 52rem; margin-inline: 0; }
.home-hero .lead, .lead { font-size: 1.15rem; color: var(--c-text-muted); }
.eyebrow { font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--c-primary); margin-bottom: var(--space-2); }
.tool-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.tool-card { display: flex; flex-direction: column; gap: var(--space-2); position: relative; }
.tool-card__cat { font-size: 0.8rem; font-weight: 600; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tool-card__title { margin: 0; }
.tool-card__title a { color: var(--c-text); text-decoration: none; }
.tool-card__title a::after { content: ''; position: absolute; inset: 0; } /* whole card clickable */
.tool-card:hover { border-color: var(--c-primary); }
.tool-card__text { color: var(--c-text-muted); flex: 1; }
.root-chooser__list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* ---------- Tool page frame ---------- */
.tool-hero { padding-block: var(--space-8) var(--space-6); }
.tool-hero__lead { font-size: 1.1rem; color: var(--c-text-muted); max-width: 48rem; }
.tool-area { /* The tool decides how this looks. Full width by default. */ }
.prose-area { max-width: 52rem; margin-inline: 0; }
@media (min-width: 72rem) { .prose-area { margin-inline: auto; } }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: var(--space-4); }
.steps__item { counter-increment: step; position: relative; padding-left: 3rem; }
.steps__item::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--c-primary); color: var(--c-primary-contrast); font-weight: 700;
}
.steps__title { margin: 0.2rem 0 0.25rem; }
.steps__item p { margin: 0; color: var(--c-text-muted); }

.prose h3 { margin-top: var(--space-6); }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: var(--space-1); }

.faq { display: grid; gap: var(--space-2); }
.faq__item { border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-bg); }
.faq__q { cursor: pointer; padding: var(--space-3) var(--space-4); font-weight: 600; list-style-position: inside; }
.faq__a { padding: 0 var(--space-4) var(--space-2); color: var(--c-text-muted); }
.faq__item[open] .faq__q { border-bottom: 1px solid var(--c-border); margin-bottom: var(--space-3); }

.not-found h1 { font-size: 4rem; color: var(--c-primary); }

@media (max-width: 40rem) {
  .site-header__inner { gap: var(--space-3); }
  .logo__text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Imprint contact details: rendered as an image from the server's env file
   (scripts/contact-image.mjs). Dark text on transparent background; inverted in dark mode. */
.contact-image { display: block; max-width: 100%; height: auto; }
@media (prefers-color-scheme: dark) {
  .contact-image { filter: invert(1) hue-rotate(180deg) brightness(0.92); }
}
