/* ============================================================
   ClackLab — Core Design System
   Shared across all tools (EN/KO/JA/TR). One engine, one look.
   Identity: precision lab instrument — mono readouts, dual
   signal colors (orange = action, phosphor green = live data).
   ============================================================ */

/* Fonts are linked directly from each page <head> (preconnect + swap)
   so they load in parallel with this stylesheet instead of behind it. */

:root {
  /* ---- Color ---- */
  --bg: #0b0e14;
  --bg-alt: #0e131b;
  --surface: #141a24;
  --surface-2: #1a2130;
  --border: #232b3a;
  --border-strong: #2f3a4d;

  --txt: #e7ecf5;
  --txt-dim: #8b96ab;
  --txt-faint: #5a6478;

  --accent: #ff5a3c;        /* signal orange — action / CTA */
  --accent-dim: #c94427;
  --accent-soft: rgba(255, 90, 60, 0.12);

  --trace: #39e6a4;         /* phosphor green — live measurement */
  --trace-dim: #1f8f66;
  --trace-soft: rgba(57, 230, 164, 0.12);

  --warn: #ffb020;
  --danger: #ff4d6a;

  /* ---- Type ---- */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;

  --step--1: clamp(0.8rem, 0.78rem + 0.1vw, 0.875rem);
  --step-0:  clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
  --step-1:  clamp(1.2rem, 1.13rem + 0.35vw, 1.4rem);
  --step-2:  clamp(1.6rem, 1.4rem + 0.9vw, 2.1rem);
  --step-3:  clamp(2.2rem, 1.8rem + 1.8vw, 3.2rem);
  --step-4:  clamp(3rem, 2.3rem + 3vw, 4.6rem);

  /* ---- Space ---- */
  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1.25rem;
  --space-4: 2rem;
  --space-5: 3.5rem;
  --space-6: 6rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 18px;

  --ease: cubic-bezier(.16, .8, .3, 1);
  --container: 1180px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }

/* Background: faint grid, instrument-panel feel, no gradient hero cliché */
body {
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  background-attachment: fixed;
  background-color: var(--bg);
  background-blend-mode: overlay;
  opacity: 1;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background: radial-gradient(ellipse 60% 40% at 50% -10%, rgba(255,90,60,0.06), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ---- Focus ---- */
:focus-visible {
  outline: 2px solid var(--trace);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- Type scale ---- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-2);
  color: var(--txt);
}
h1 { font-size: var(--step-4); line-height: 1.05; letter-spacing: -0.02em; }
h2 { font-size: var(--step-3); line-height: 1.1; }
h3 { font-size: var(--step-2); line-height: 1.2; }
h4 { font-size: var(--step-1); line-height: 1.3; }
p { margin: 0 0 var(--space-3); color: var(--txt-dim); max-width: 68ch; }
small, .eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--trace);
}

/* Data readouts — every live number on the site uses this */
.data, .readout {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--trace);
}

/* ---- Layout ---- */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-3);
  position: relative;
  z-index: 1;
}
.grid {
  display: grid;
  gap: var(--space-3);
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---- Nav ---- */
.site-nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: rgba(11, 14, 20, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-nav .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-1);
  display: flex; align-items: center; gap: var(--space-1);
}
.site-nav .brand .dot { color: var(--accent); }
.site-nav ul { display: flex; gap: var(--space-3); align-items: center; }
.site-nav a.nav-link { color: var(--txt-dim); font-size: var(--step--1); transition: color .15s var(--ease); }
.site-nav a.nav-link:hover, .site-nav a.nav-link[aria-current="page"] { color: var(--txt); }

/* ---- Language switcher ---- */
.lang-switch { display: flex; gap: 4px; }
.lang-switch a {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt-faint);
  transition: all .15s var(--ease);
}
.lang-switch a:hover { color: var(--txt); border-color: var(--border-strong); }
.lang-switch a[aria-current="true"] { color: var(--bg); background: var(--trace); border-color: var(--trace); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0.85em 1.6em;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--step-0);
  transition: transform .15s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #ff6f54; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--txt); }
.btn-ghost:hover { border-color: var(--trace); color: var(--trace); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}
.card-tool {
  display: flex; flex-direction: column; gap: var(--space-1);
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.card-tool:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card-tool .tag {
  font-family: var(--font-mono); font-size: var(--step--1);
  color: var(--txt-faint); text-transform: uppercase; letter-spacing: 0.06em;
}
.card-tool h3 { font-size: var(--step-1); }
.card-tool p { font-size: var(--step--1); margin-bottom: var(--space-2); }

/* ---- Signature element: signal bars (VU-meter) ---- */
.signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
}
.signal-bars span {
  width: 3px;
  background: var(--trace-dim);
  border-radius: 1px;
  height: 30%;
  transition: background .2s var(--ease);
}
.signal-bars.live span {
  background: var(--trace);
  animation: signal-pulse 1.1s ease-in-out infinite;
}
.signal-bars span:nth-child(1) { animation-delay: 0s; }
.signal-bars span:nth-child(2) { animation-delay: .15s; }
.signal-bars span:nth-child(3) { animation-delay: .3s; }
.signal-bars span:nth-child(4) { animation-delay: .1s; }
.signal-bars span:nth-child(5) { animation-delay: .25s; }
@keyframes signal-pulse {
  0%, 100% { height: 25%; }
  50% { height: 100%; }
}

/* ---- Result panel (used by every tool) ---- */
.result-panel {
  text-align: center;
  padding: var(--space-5) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.result-panel .big-number {
  font-family: var(--font-mono);
  font-size: var(--step-4);
  font-weight: 600;
  color: var(--trace);
  line-height: 1;
}
.result-panel .unit {
  font-family: var(--font-mono);
  color: var(--txt-faint);
  font-size: var(--step-0);
  margin-left: 6px;
}
.result-panel .best-score {
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--txt-faint);
}
.result-panel .best-score .val { color: var(--accent); }

/* Test zone — the clickable/interactive surface */
.test-zone {
  display: flex; align-items: center; justify-content: center;
  min-height: 260px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.test-zone:hover { border-color: var(--trace-dim); }
.test-zone.active { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.test-zone .prompt {
  font-family: var(--font-display);
  font-size: var(--step-1);
  color: var(--txt-dim);
}

/* ---- FAQ ---- */
.faq details {
  border-bottom: 1px solid var(--border);
  padding: var(--space-2) 0;
}
.faq summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-0);
  list-style: none;
  display: flex; justify-content: space-between; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.4em; }
.faq details[open] summary::after { content: "\2212"; }
.faq details p { margin-top: var(--space-2); }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-4) 0;
  color: var(--txt-faint);
  font-size: var(--step--1);
}
.site-footer a { color: var(--txt-dim); }
.site-footer a:hover { color: var(--trace); }

/* ---- Motion respect ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Homepage + article layout (aligned build)
   System: centered hero and section heads, full-width tool grid
   closed by a wide banner card, centered readable article column.
   ============================================================ */
.hero {
  padding: var(--space-6) 0 var(--space-4);
  position: relative;
  z-index: 1;
  text-align: center;
}
.hero h1 {
  font-size: var(--step-3);
  line-height: 1.14;
  text-wrap: balance;
}
.hero .lede {
  font-size: var(--step-1);
  color: var(--txt);
  max-width: 62ch;
  margin: 0 auto;
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

#tools { padding-bottom: var(--space-4); }
#tools .section-head { text-align: center; margin-bottom: var(--space-3); }
.card.card-tool { color: inherit; }
.card-tool .tag { color: var(--accent); }
.card-tool .go {
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--trace);
}
.card-tool:hover .go { text-decoration: underline; }

/* 10 tools in a 3-col grid leaves one orphan: turn it into a wide banner card */
#tools .grid > a:last-child:nth-child(3n+1) {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
}
#tools .grid > a:last-child:nth-child(3n+1) h3 { margin: 0; }
#tools .grid > a:last-child:nth-child(3n+1) p { flex: 1; margin: 0; }

/* Article: centered column, left-aligned text inside for readability.
   Works for Latin, Hangul, kana and kanji line lengths alike. */
.article {
  max-width: 740px;
  margin: 0 auto;
  padding-bottom: var(--space-5);
}
.article p { max-width: none; }
.article section { margin-top: var(--space-4); }
.article section.faq h2 { margin-bottom: var(--space-2); }

.tool-article {
  max-width: 740px;
  margin: var(--space-5) auto 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.tool-article p { max-width: none; }
.tool-article h2 { margin-bottom: var(--space-3); }

/* ---- Mobile ---- */
@media (max-width: 620px) {
  .site-nav { padding: var(--space-2); }
  .site-nav .brand { font-size: var(--step-0); }
  .lang-switch a { padding: 3px 7px; }
  .hero { padding-top: var(--space-5); }
  .hero h1 { font-size: clamp(1.7rem, 1.35rem + 2.6vw, 2.15rem); line-height: 1.2; }
  .hero-cta .btn { flex: 1 1 auto; min-width: 200px; }
  #tools .grid > a:last-child:nth-child(3n+1) { flex-direction: column; align-items: flex-start; }
  #tools .grid > a:last-child:nth-child(3n+1) p { margin: 0 0 var(--space-2); }
}

/* Article links (internal linking) */
.tool-article a, .article a {
  color: var(--trace);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tool-article a:hover, .article a:hover { color: var(--accent); }

/* ============================================================
   Header menu (categories + dropdowns + burger) and site footer
   ============================================================ */
.site-nav .nav-left { display: flex; align-items: center; gap: var(--space-2); }
.nav-burger {
  display: none; flex-direction: column; gap: 4px;
  padding: 9px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.nav-burger span { display: block; width: 18px; height: 2px; background: var(--txt); border-radius: 1px; transition: transform .2s var(--ease), opacity .2s var(--ease); }
body.nav-open .nav-burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.nav-open .nav-burger span:nth-child(2) { opacity: 0; }
body.nav-open .nav-burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.nav-menu { display: flex; align-items: center; gap: var(--space-1); }
.nav-item { position: relative; }
a.nav-drop-toggle { padding: 8px 10px; border-radius: var(--radius-sm); }
a.nav-drop-toggle::after { content: "\25BE"; font-size: 0.7em; color: var(--txt-faint); margin-left: 5px; }
.nav-drop {
  position: absolute; top: 100%; left: 0; min-width: 280px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); padding: var(--space-1);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  opacity: 0; visibility: hidden; transform: translateY(6px); z-index: 30;
  transition: opacity .15s var(--ease), transform .15s var(--ease), visibility .15s;
}
.nav-item:hover .nav-drop, .nav-item:focus-within .nav-drop {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.nav-drop a { display: block; padding: 8px 10px; border-radius: var(--radius-sm); font-size: var(--step-0); color: var(--txt); }
.nav-drop a:hover { background: var(--surface-2); }
.nav-drop a span { display: block; color: var(--txt-faint); font-size: 0.78em; line-height: 1.35; margin-top: 2px; }

@media (max-width: 900px) {
  .nav-burger { display: flex; }
  .nav-menu {
    position: fixed; top: 54px; left: 0; right: 0; z-index: 25;
    flex-direction: column; align-items: stretch; gap: 0;
    background: rgba(11, 14, 20, 0.98); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: var(--space-2) var(--space-3) var(--space-3);
    max-height: calc(100vh - 54px); overflow-y: auto;
    opacity: 0; visibility: hidden; transform: translateY(-8px); pointer-events: none;
    transition: opacity .2s var(--ease), transform .2s var(--ease), visibility .2s;
  }
  body.nav-open .nav-menu { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
  .nav-item { padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
  .nav-item:last-child { border-bottom: 0; }
  .nav-drop {
    position: static; opacity: 1; visibility: visible; transform: none;
    box-shadow: none; border: 0; background: transparent; padding: 0 0 0 var(--space-2); min-width: 0;
  }
  .nav-drop a { font-size: var(--step--1); }
  a.nav-drop-toggle { display: inline-block; }
}

/* ---- Footer ---- */
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: var(--space-4); }
.footer-grid h4 {
  font-family: var(--font-mono); font-size: var(--step--1); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--trace);
  margin: 0 0 var(--space-2);
}
.footer-grid a { display: block; color: var(--txt-dim); font-size: var(--step--1); padding: 3px 0; }
.footer-grid a:hover { color: var(--txt); }
.footer-brand .brand {
  font-family: var(--font-display); font-weight: 700; font-size: var(--step-1);
  display: flex; align-items: center; gap: var(--space-1);
}
.footer-brand .brand .dot { color: var(--accent); }
.footer-brand p { margin: var(--space-2) 0 0; font-size: var(--step--1); max-width: 36ch; color: var(--txt-faint); }
.footer-bottom {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3);
  justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border); margin-top: var(--space-4); padding-top: var(--space-3);
  font-size: var(--step--1); color: var(--txt-faint);
}
.footer-legal a { color: var(--txt-dim); }
.footer-legal a:hover { color: var(--trace); }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .footer-grid { grid-template-columns: 1fr; } .footer-bottom { justify-content: center; text-align: center; } }
