/* ============================================================
   GIGO Design System — 義剛: Disciplined Authority
   ============================================================ */

/* --- Custom Properties --- */
:root {
  /* Colors — dark theme (default) */
  --bg:            #08090a;
  --bg-subtle:     #111214;
  --bg-code:       #181a1e;
  --bg-elevated:   #1a1c20;
  --text:          #e2e4e8;
  --text-secondary:#858a93;
  --text-muted:    #8a8f98;
  --accent:        #9bb8d3;
  --accent-hover:  #b8d0e8;
  --accent-dim:    rgba(155, 184, 211, 0.12);
  --accent-glow:   rgba(155, 184, 211, 0.06);
  --border:        #1e2028;
  --border-code:   #2a2d35;
  --border-quote:  #9bb8d3;

  /* Typography */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono:    'SF Mono', SFMono-Regular, ui-monospace, 'Cascadia Code', Consolas, 'Liberation Mono', Menlo, monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  2rem;
  --text-4xl:  2.5rem;
  --text-5xl:  clamp(3rem, 6vw, 5rem);

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Radii */
  --radius-sm:   3px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-full: 999px;

  /* Layout */
  --max-width: 800px;
  --article-width: 680px;
  --nav-height: 3.5rem;
}

/* Light theme overrides */
[data-theme="light"] {
  --bg:            #f8f9fa;
  --bg-subtle:     #eef0f2;
  --bg-code:       #e8eaed;
  --bg-elevated:   #fff;
  --text:          #14161a;
  --text-secondary:#50555e;
  --text-muted:    #5a5f68;
  --accent:        #2d6a9f;
  --accent-hover:  #1d5080;
  --accent-dim:    rgba(45, 106, 159, 0.08);
  --accent-glow:   rgba(45, 106, 159, 0.04);
  --border:        #dde0e4;
  --border-code:   #cdd0d4;
  --border-quote:  #2d6a9f;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.no-transition,
body.no-transition * {
  transition: none !important;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-hover);
}

/* --- Focus (WCAG 2.4.7) --- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* --- Skip Link (WCAG 2.4.1) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  z-index: 200;
  text-decoration: none;
}

.skip-link:focus { top: 0; }

/* --- Utility --- */
.text-secondary { color: var(--text-secondary); }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }

p { margin-bottom: var(--space-md); }

/* Prevent em-dashes from breaking onto their own line */
p, li, td, blockquote p {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.section {
  padding: var(--space-xl) 0;
}

main > .section:last-child,
main > section:last-child {
  padding-bottom: var(--space-3xl);
}

.section--flush { padding-bottom: 0; }
.section--flush-top { padding-top: 0; }
.section--center { text-align: center; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* --- Brand Mark --- */
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xl);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-xs);
  letter-spacing: -0.02em;
}

.brand:hover { color: var(--text); text-decoration: none; }

.brand-kanji {
  font-size: 1.3em;
  line-height: 1;
}

/* --- Navigation --- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background-color: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.3s ease;
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  position: relative;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  list-style: none;
}

.nav-links a {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.nav-links a:hover { color: var(--text); text-decoration: none; }

.nav-links li {
  display: flex;
  align-items: center;
}

.nav-links svg {
  display: block;
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.4em;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

#theme-toggle .icon-moon { display: none; }
#theme-toggle .icon-sun { display: block; }

#theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-secondary);
  background-color: var(--accent-dim);
}

#nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: var(--space-sm);
  min-width: 44px;
  min-height: 44px;
  font-size: var(--text-lg);
  line-height: 1;
}

#nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background-color: currentColor;
  margin: 4px 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

@media (max-width: 768px) {
  #nav-toggle { display: block; }
  #nav-menu {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0; right: 0;
    background-color: color-mix(in srgb, var(--bg) 95%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: var(--space-md) var(--space-lg);
    flex-direction: column;
    gap: var(--space-md);
  }
  #nav-menu.open { display: flex; }
}

/* --- Footer --- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: var(--space-xl) 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
}

.footer-links a {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.footer-links a:hover { color: var(--text-secondary); }

/* --- Code Blocks --- */
pre, code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

code {
  background-color: var(--bg-code);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
}

pre {
  background-color: var(--bg-code);
  border: 1px solid var(--border-code);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  overflow-x: auto;
  margin-bottom: var(--space-lg);
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* --- Data Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  font-size: var(--text-sm);
}

caption {
  caption-side: top;
  text-align: left;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  font-style: italic;
}

th, td {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
}

th {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:nth-child(even) {
  background-color: var(--bg-subtle);
}

/* --- Badges --- */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 0.2em 0.6em;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* --- CTA Buttons --- */
.btn {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.7em 1.8em;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background-color: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
  box-shadow: 0 0 20px var(--accent-dim);
}

.btn-secondary {
  background-color: transparent;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

.btn-secondary:hover {
  background-color: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* --- Pull Quotes --- */
blockquote,
.pull-quote {
  border-left: 3px solid var(--border-quote);
  padding: var(--space-lg) var(--space-xl);
  margin: var(--space-xl) 0;
  font-size: var(--text-lg);
  font-style: italic;
  color: var(--text-secondary);
  background-color: var(--accent-glow);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

blockquote p:last-child,
.pull-quote p:last-child { margin-bottom: 0; }

blockquote cite,
.pull-quote cite {
  display: block;
  font-size: var(--text-sm);
  font-style: normal;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* --- Article Body --- */
.article-body {
  max-width: var(--article-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.article-body h2 { margin-top: var(--space-xl); }
.article-body h3 { margin-top: var(--space-lg); }

.article-body blockquote,
.article-body .pull-quote {
  margin: var(--space-2xl) 0;
}

/* --- Table Wrapper --- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-lg) 0;
}

.table-wrapper table { margin: 0; }

/* --- Finding List --- */
.finding-list {
  list-style: none;
  padding: 0;
  margin: var(--space-xl) 0;
}

.finding-list li {
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-sm);
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent);
}

.finding-list li strong {
  color: var(--accent);
}

/* ============================================================
   HERO — The main event
   ============================================================ */
.hero {
  position: relative;
  padding: var(--space-4xl) 0 var(--space-3xl);
  text-align: center;
  overflow: hidden;
}

/* Giant kanji watermark — the brand's signature */
.hero::before {
  content: '義剛';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(14rem, 35vw, 28rem);
  font-weight: 700;
  color: var(--accent-dim);
  pointer-events: none;
  white-space: nowrap;
  z-index: 0;
  line-height: 1;
  opacity: 0.4;
}

.hero > .container {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: var(--text-5xl);
  font-weight: 700;
  margin-bottom: var(--space-xs);
  letter-spacing: -0.03em;
}

.hero h1 .brand-kanji {
  font-size: 1.15em;
  color: var(--accent);
}

.hero .subtitle {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--accent);
  margin-bottom: var(--space-lg);
  letter-spacing: -0.01em;
}

.hero .hero-desc {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto var(--space-xl);
  line-height: 1.7;
}

.cta-group {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.install-cmd {
  display: inline-block;
  background-color: var(--bg-code);
  border: 1px solid var(--border-code);
  border-radius: var(--radius-md);
  padding: 0.6em 1.4em;
  margin-top: var(--space-lg);
}

.install-cmd code {
  background: none;
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
}

@media (max-width: 768px) {
  .hero { padding: var(--space-3xl) 0 var(--space-2xl); }
  .hero h1 { font-size: var(--text-4xl); }
  .hero .subtitle { font-size: var(--text-lg); }
  .hero::before { font-size: 10rem; }
}

/* ============================================================
   HOW IT WORKS — Numbered steps with visual weight
   ============================================================ */
.how-it-works {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin: var(--space-xl) 0;
}

.how-it-works-step {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.how-it-works-step:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background-color: var(--bg-elevated);
}

.how-it-works-step .step-number {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-3xl);
  color: var(--accent);
  margin-bottom: var(--space-sm);
  letter-spacing: -0.02em;
}

.how-it-works-step .step-label {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.how-it-works-step .step-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.how-it-works--3col {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
  .how-it-works,
  .how-it-works--3col { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   RESULTS — Achievement style, not report style
   ============================================================ */
.results-highlight {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin: var(--space-xl) 0;
}

.results-stat {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.results-stat:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background-color: var(--bg-elevated);
}

.results-stat .stat-number {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.results-stat .stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.4;
}

@media (max-width: 768px) {
  .results-highlight {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   QUICK START
   ============================================================ */
.quick-start-steps {
  font-size: var(--text-lg);
  padding-left: var(--space-xl);
}

.quick-start-steps li {
  margin-bottom: var(--space-md);
}

/* ============================================================
   404 PAGE
   ============================================================ */
.page-404 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 60vh;
}

.page-404 h1 {
  font-size: 4rem;
  margin-bottom: var(--space-sm);
}

.page-404 p {
  color: var(--text-secondary);
  font-size: var(--text-lg);
}

.page-404 ul {
  list-style: none;
  padding: 0;
  margin-top: var(--space-md);
}

/* ============================================================
   SUBTLE ENTRANCE ANIMATIONS
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  .section,
  .hero {
    animation: fadeInUp 0.5s ease both;
  }

  .section:nth-child(2) { animation-delay: 0.1s; }
  .section:nth-child(3) { animation-delay: 0.15s; }
  .section:nth-child(4) { animation-delay: 0.2s; }
  .section:nth-child(5) { animation-delay: 0.25s; }
  .section:nth-child(6) { animation-delay: 0.3s; }
  .section:nth-child(7) { animation-delay: 0.35s; }

  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(12px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .site-nav,
  .site-footer,
  #theme-toggle,
  #nav-toggle { display: none !important; }

  body { background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
  .container { max-width: 100%; }
  .hero::before { display: none; }
}

.back-to-top {
  text-align: center;
  margin-top: var(--space-3xl);
}
