/* =====================================================================
 * Aware — Shared site chrome
 * Nav, footer, buttons, language toggle, mobile sheet, and the base
 * locale-aware typography foundation. Linked AFTER colors_and_type.css on
 * every page (home, blog, legal) so chrome renders identically everywhere.
 * Page-specific section styles stay inline in each page.
 * ===================================================================== */

/* ─────────────────────────────────────────────────────────────────────
 * Foundation — locale-aware type + visibility
 * ───────────────────────────────────────────────────────────────────── */
:root {
  --max:        1216px;   /* desktop content width */
  --max-narrow: 960px;
  --gutter:     32px;

  /* Locale-aware aliases. EN defaults; JP overrides below. */
  --font-mono-role: var(--font-mono);
  --font-sans-role: var(--font-sans);
  --lh-body:    1.6;
  --lh-subhead: 1.5;

  /* Type scale — shared with chrome (button + label sizes) */
  --fs-mini:    clamp(19px, 1.6vw, 22px);
  --fs-subhead: clamp(17px, 1.4vw, 20px);
  --fs-body:    clamp(16px, 1.1vw, 17px);
  --fs-label:   clamp(12px, 0.9vw, 13px);
  --fs-source:  clamp(12px, 0.9vw, 13px);
  --fs-button:  15px;
}

/* Skip-to-content link — WCAG 2.4.1 (visible only on keyboard focus) */
.skip-link {
  position: fixed; left: 12px; top: -56px; z-index: 100;
  background: var(--primary-accent); color: var(--text-inverse);
  font-family: var(--font-mono-role); font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: var(--radius-md); text-decoration: none;
  transition: top var(--dur-2, 200ms) var(--ease-out, ease);
}
.skip-link:focus { top: 12px; outline: 2px solid var(--text-inverse); outline-offset: 2px; }
main:focus { outline: none; }

/* JP locale overrides — from 02-JP-OVERLAY.md */
html[data-locale="ja"] {
  --font-mono-role: "M PLUS 1 Code", "JetBrains Mono", ui-monospace, monospace;
  --font-sans-role: "IBM Plex Sans JP", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  /* +1px body/subhead — JP is visually denser at the same px */
  --fs-body:    clamp(17px, 1.2vw, 18px);
  --fs-subhead: clamp(18px, 1.5vw, 21px);
  --lh-body:    1.75;
  --lh-subhead: 1.6;
}
html[data-locale="ja"] body {
  letter-spacing: -0.02em;
  line-break: strict;
  word-break: normal;
  /* Wrap naturally at Japanese break points; do not force-break inside words. */
  overflow-wrap: normal;
}
html[data-locale="ja"] :is(h1, h2, h3, h4, p, li) {
  hanging-punctuation: allow-end;
}

/* Locale visibility: only the active locale's text shows */
html[data-locale="en"] [lang="ja"], html[data-locale="en"] [lang="id"] { display: none !important; }
html[data-locale="ja"] [lang="en"], html[data-locale="ja"] [lang="id"] { display: none !important; }
html[data-locale="id"] [lang="en"], html[data-locale="id"] [lang="ja"] { display: none !important; }

.mono, h1, h2, h3, h4, .eyebrow, .data, .btn, .seclabel, .minititle, .step-num, .src-label {
  font-family: var(--font-mono-role);
  font-feature-settings: "tnum" 1, "cv11" 1;
}

/* ─── Layout ─── */
.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  height: 48px;
  min-width: 160px;
  padding: 0 24px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--fs-button);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: box-shadow var(--dur-2) var(--ease-out),
              background var(--dur-2) var(--ease-out),
              color var(--dur-2) var(--ease-out);
}
.btn-primary {
  background: var(--primary-accent);
  color: var(--text-inverse);
}
.btn-primary:hover { box-shadow: 0 0 0 3px var(--primary-accent-trs-60); }
.btn-primary:active { background: #e8af26; }
.btn-primary:focus-visible { outline: 2px solid var(--primary-accent); outline-offset: 2px; }
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-plus);
}
.btn-ghost:hover { background: var(--bg-card); }
.btn-block { width: 100%; }

/* Primary CTA micro-interaction (also picks up the inline → glyph) */
.btn-primary {
  transition: background var(--dur-2) var(--ease-out),
              color var(--dur-2) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out),
              transform var(--dur-2) var(--ease-out);
}
.btn-primary [aria-hidden="true"] {
  display: inline-block;
  transition: transform var(--dur-2) var(--ease-out);
}
@media (hover: hover) {
  .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 0 3px var(--primary-accent-trs-60),
                0 8px 24px rgba(255, 194, 51, 0.18);
  }
  .btn-primary:hover [aria-hidden="true"] { transform: translateX(3px); }
  .btn-ghost:hover { border-color: var(--primary-accent-trs-30); }
}
.btn-primary:active { transform: translateY(0); }

/* ─── Nav (sticky, global) ─── */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: 64px;
  background: var(--bg-card-trs-95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.nav .row {
  height: 100%;
  display: flex; align-items: center; gap: 32px;
}
.nav .wordmark {
  color: var(--text-primary);
  display: inline-flex; align-items: center;
  height: 28px;
}
.nav .wordmark svg { display: block; width: auto; height: 22px; }
.nav .links {
  display: flex; gap: 28px;
  margin-left: 24px;
}
.nav .links a {
  font-family: var(--font-mono-role);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  transition: color var(--dur-2) var(--ease-out);
  padding: 6px 0;
  white-space: nowrap;
}
.nav .links a:hover { color: var(--text-primary); }
.nav .right {
  margin-left: auto;
  display: flex; gap: 16px; align-items: center;
}
.lang {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 2px;
  height: 32px;
  font-family: var(--font-mono-role);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.lang button {
  height: 26px;
  min-width: 38px;
  padding: 0 10px;
  background: transparent;
  color: var(--text-muted);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
  transition: background var(--dur-2), color var(--dur-2);
}
.lang button.on {
  background: var(--bg-text-box-in-card);
  color: var(--text-primary);
}
.lang button:disabled,
.lang button[aria-disabled="true"] {
  cursor: not-allowed;
  color: var(--text-muted);
}
/* Bahasa button uses dual labels: full "Bahasa" by default, short "ID" only on
   the narrowest mobiles (overridden in the ≤420px media query). */
.lang button .lang-short { display: none; }
.nav .cta-nav {
  height: 36px; min-width: 0; padding: 0 16px;
  font-size: 13px;
}

/* Sticky nav darkens / adds shadow once the hero scrolls past */
.nav {
  transition: background var(--dur-3) var(--ease-out),
              border-bottom-color var(--dur-3) var(--ease-out),
              box-shadow var(--dur-3) var(--ease-out);
}
.nav.scrolled {
  background: rgba(11, 11, 11, 0.88);
  border-bottom-color: var(--border-plus);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Language toggle: ensure the EN/JP labels stay in JetBrains Mono
   regardless of active locale — they're language tokens, not copy. */
.lang, .lang button { font-family: "JetBrains Mono", ui-monospace, monospace !important; }

/* ─── Mobile hamburger — hidden on desktop, replaces anchor links on phones ─── */
.nav-burger {
  display: none;
  width: 38px; height: 38px;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 0; cursor: pointer;
  position: relative;
  color: var(--text-primary);
}
.nav-burger span {
  position: absolute; left: 10px; right: 10px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  transition: top var(--dur-2) var(--ease-out),
              transform var(--dur-2) var(--ease-out),
              opacity var(--dur-2) var(--ease-out);
}
.nav-burger span:nth-child(1) { top: 13px; }
.nav-burger span:nth-child(2) { top: 18px; }
.nav-burger span:nth-child(3) { top: 23px; }
.nav-burger[aria-expanded="true"] span:nth-child(1) { top: 18px; transform: rotate(45deg); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { top: 18px; transform: rotate(-45deg); }

.nav-sheet {
  position: fixed;
  top: 64px; left: 0; right: 0;
  background: rgba(11, 11, 11, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--hairline);
  padding: 16px var(--gutter) 20px;
  display: flex; flex-direction: column;
  z-index: 49;
  transform: translateY(-8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-3) var(--ease-out),
              transform var(--dur-3) var(--ease-out),
              visibility 0s linear var(--dur-3);
}
.nav-sheet.open {
  opacity: 1; transform: none; visibility: visible;
  transition-delay: 0s;
}
.nav-sheet a {
  font-family: var(--font-mono-role);
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
  padding: 18px 4px;
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.nav-sheet a:last-child { border-bottom: 0; }
.nav-sheet a .arr {
  color: var(--text-muted);
  font-family: var(--font-mono-role);
  font-size: 14px;
}
html[data-locale="ja"] .nav-sheet a { font-size: 16px; }

@media (max-width: 900px) {
  .nav-burger { display: inline-block; }
  /* Tighter mobile spacing so logo + burger + lang + CTA all fit at 360px */
  .nav .row { gap: 8px; }
  .nav .right { gap: 8px; }
  .nav-burger { margin-right: 4px; }
}
@media (min-width: 901px) {
  .nav-sheet { display: none !important; }
}

/* ─── Footer ─── */
footer.foot {
  border-top: 1px solid var(--hairline);
  padding: 80px 0 48px;
}
footer .top {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
  padding-bottom: 56px;
  border-bottom: 1px solid var(--hairline);
}
footer .brand .wordmark svg { width: auto; height: 28px; display: block; color: var(--text-primary); }
footer .brand .tagline {
  margin-top: 24px;
  font-family: var(--font-mono-role);
  font-size: var(--fs-mini);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  max-width: 28ch;
  letter-spacing: -0.005em;
}
footer h4 {
  font-family: var(--font-mono-role);
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 16px;
}
footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
footer ul li {
  font-family: var(--font-sans-role);
  font-size: var(--fs-body);
  color: var(--text-secondary);
  line-height: 1.55;
}
footer ul li a {
  color: var(--text-secondary);
  transition: color var(--dur-2);
}
footer ul li a:hover { color: var(--text-primary); }
footer .bottom {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  font-family: var(--font-mono-role);
  font-size: var(--fs-source);
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
footer .bottom .legal-links {
  display: flex; gap: 24px; align-items: center;
}
footer .bottom .legal-links a:hover { color: var(--text-primary); }
footer .bottom .nda {
  margin-top: 16px;
  grid-column: 1 / -1;
  font-family: var(--font-sans-role);
  font-size: var(--fs-source);
  color: var(--text-muted);
  line-height: 1.4;
}

/* ─── Footer demo capture (compact email form) ─── */
.foot-contact { display: flex; flex-direction: column; }
.foot-contact-note {
  font-family: var(--font-sans-role);
  font-size: var(--fs-body);
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0 0 16px;
  max-width: 34ch;
  text-wrap: pretty;
}
.foot-demo-form {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
}
.foot-demo-form input[type="email"] {
  flex: 1; min-width: 0;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-text-box-in-card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans-role);
  font-size: 16px;             /* >=16px prevents iOS zoom on focus */
  line-height: 44px;
  outline: 0;
  transition: border-color var(--dur-2) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out);
}
.foot-demo-form input[type="email"]::placeholder { color: var(--text-muted); }
.foot-demo-form input[type="email"]:focus {
  border-color: var(--primary-accent-trs-60);
  box-shadow: 0 0 0 4px rgba(255, 194, 51, 0.10);
}
.foot-demo-form .btn {
  height: 44px; min-width: 0;
  padding: 0 18px;
  font-size: 14px;
}
.foot-demo-form .form-status { flex-basis: 100%; }

/* ─── Form status line (shared by home + footer capture) ─── */
.form-status {
  font-family: var(--font-mono-role);
  font-size: var(--fs-source);
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  min-height: 1.4em;
  margin: 0;
}
.form-status.is-error { color: var(--negative); }
.form-status.is-ok    { color: var(--positive); }

/* ─────────────────────────────────────────────────────────────────────
 * Locale overrides — NAV / FOOTER / lang / form chrome ONLY
 * (page-section locale overrides stay inline in each page)
 * ───────────────────────────────────────────────────────────────────── */
html[data-locale="ja"] footer h4       { letter-spacing: 0.02em; text-transform: none; font-size: calc(var(--fs-label) + 1px); }
html[data-locale="ja"] footer .bottom  { letter-spacing: 0; }
html[data-locale="ja"] .form-status    { letter-spacing: 0; }
html[data-locale="ja"] .nav .links a   { letter-spacing: 0; font-size: 14px; }
html[data-locale="ja"] footer .brand .tagline { line-height: 1.5; letter-spacing: -0.02em; max-width: 24ch; }

/* ─── Responsive — nav + footer (≤900px) ─── */
@media (max-width: 900px) {
  :root { --gutter: 20px; }

  /* Nav: anchor links collapse */
  .nav .links { display: none; }
  .nav .row { gap: 12px; }
  /* Three-locale toggle (EN / 日本語 / Bahasa) needs tighter mobile sizing to fit alongside the CTA at 375px. */
  .lang { height: 30px; font-size: 11px; }
  .lang button { min-width: 0; padding: 0 5px; }
  .nav .cta-nav { padding: 0 10px; font-size: 12px; height: 32px; }
}

/* ─── Phone tweaks (≤480px) — footer stacks ─── */
@media (max-width: 480px) {
  footer.foot { padding: 56px 0 32px; }
  footer .top { grid-template-columns: 1fr; gap: 40px; padding-bottom: 40px; }
  footer .bottom { grid-template-columns: 1fr; align-items: flex-start; }
  footer .bottom .legal-links { flex-wrap: wrap; gap: 16px 20px; }
  .foot-demo-form .btn { width: 100%; }
}

/* ─── Narrowest mobile (≤420px) — "Bahasa" → "ID" pill swap ─── */
@media (max-width: 420px) {
  .lang button .lang-long { display: none; }
  .lang button .lang-short { display: inline; }
}

/* ─── Ultra-narrow (≤360px) — pull nav cluster in further ─── */
@media (max-width: 360px) {
  :root { --gutter: 16px; }
  .nav .row { gap: 8px; }
  .nav .right { gap: 6px; }
  .lang button { padding: 0 4px; }
  .nav .cta-nav { padding: 0 8px; font-size: 11px; }
}

/* Reduced motion respect (chrome transitions) */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
