@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* =============================================
   BASE RESET & TOKENS
   ============================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #ffffff;
  --color-fg: #000000;
  --color-accent: #000000;
  --color-border: #000000;
  --color-muted: #555555;
  --color-subtle: #eeeeee;
  --color-hover: #222222;
  --color-surface: #f5f5f5;

  --font-sans: 'Inter', Helvetica, Arial, sans-serif;
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --base: 8px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;
  --space-10: 80px;
  --space-12: 96px;

  --header-height: 64px;
  --sidebar-width: 220px;
  --content-max: 860px;
  --radius-card: 10px;

  --transition-base: 200ms ease;
  --transition-reveal: 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-sans);
  font-weight: var(--font-weight-regular);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-fg);
  background-color: var(--color-bg);
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

address {
  font-style: normal;
}

/* =============================================
   SCROLL MARGIN FOR FIXED HEADER
   ============================================= */

div[id] {
  scroll-margin-top: calc(var(--header-height) + 16px);
}

/* =============================================
   SITE WRAPPER
   ============================================= */

.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* =============================================
   HEADER
   ============================================= */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--color-fg);
  color: var(--color-bg);
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--color-fg);
}

.header-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
}

.logo-img {
  height: 32px;
  width: auto;
}

.logo-text {
  font-size: 1.125rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.03em;
  color: var(--color-bg);
  white-space: nowrap;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.header-nav::-webkit-scrollbar {
  display: none;
}

.header-nav-link {
  color: var(--color-bg);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.02em;
  padding: 0 var(--space-1);
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
  opacity: 0.75;
  transition: opacity var(--transition-base);
  border-bottom: 1px solid transparent;
}

.header-nav-link:hover,
.header-nav-link:focus-visible {
  opacity: 1;
  border-bottom-color: var(--color-bg);
}

.header-cta {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-2);
  background: var(--color-bg);
  color: var(--color-fg);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.04em;
  border: 1px solid var(--color-bg);
  white-space: nowrap;
  transition: background var(--transition-base), color var(--transition-base);
  flex-shrink: 0;
}

.header-cta:hover,
.header-cta:focus-visible {
  background: var(--color-hover);
  color: var(--color-bg);
  border-color: var(--color-hover);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1);
  min-height: 44px;
  min-width: 44px;
  color: var(--color-bg);
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

/* =============================================
   LAYOUT GRID
   ============================================= */

.layout-grid {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  margin-top: var(--header-height);
  flex: 1;
  min-height: 0;
}

/* =============================================
   SIDEBAR
   ============================================= */

.sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  scrollbar-width: thin;
  border-right: 1px solid var(--color-border);
  background: var(--color-bg);
  padding: var(--space-4) var(--space-3);
  align-self: start;
  z-index: 10;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--color-subtle);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-label {
  font-size: 0.6875rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.sidebar-toc {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-toc li a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-1);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-medium);
  color: var(--color-fg);
  border-left: 2px solid transparent;
  min-height: 44px;
  transition: border-color var(--transition-base), background var(--transition-base);
  line-height: 1.3;
}

.sidebar-toc li a:hover,
.sidebar-toc li a:focus-visible {
  border-left-color: var(--color-fg);
  background: var(--color-surface);
}

.sidebar-divider {
  height: 1px;
  background: var(--color-border);
}

.sidebar-note {
  font-size: 0.75rem;
  color: var(--color-muted);
  line-height: 1.5;
}

/* =============================================
   MAIN CONTENT
   ============================================= */

.main-content {
  min-width: 0;
}

.page-article {
  display: flex;
  flex-direction: column;
}

/* =============================================
   HERO SECTION
   ============================================= */

.hero-section {
  position: relative;
  min-height: 45vh;
  display: flex;
  align-items: flex-end;
  background: var(--color-fg);
  color: var(--color-bg);
  overflow: hidden;
  padding: var(--space-8) var(--space-8) var(--space-8);
}

.hero-grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--content-max);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.hero-eyebrow {
  font-size: 0.6875rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}

.hero-h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--color-bg);
}

.hero-desc {
  font-size: 1rem;
  font-weight: var(--font-weight-light);
  color: rgba(255,255,255,0.75);
  max-width: 480px;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-1);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  background: var(--color-bg);
  color: var(--color-fg);
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.03em;
  border: 1px solid var(--color-bg);
  transition: background var(--transition-base), color var(--transition-base);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--color-subtle);
  color: var(--color-fg);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  background: transparent;
  color: var(--color-bg);
  font-size: 0.875rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.03em;
  border: 1px solid rgba(255,255,255,0.4);
  transition: border-color var(--transition-base), background var(--transition-base);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  border-color: var(--color-bg);
  background: rgba(255,255,255,0.1);
}

/* =============================================
   CONTENT SECTION
   ============================================= */

.content-section {
  padding: var(--space-8);
  max-width: calc(var(--content-max) + var(--space-8) * 2);
}

.content-body {
  max-width: var(--content-max);
}

/* =============================================
   CONTENT TYPOGRAPHY
   ============================================= */

.content-body h2,
.content-body h3 {
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.content-body h2 {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
}

.content-body h3 {
  font-size: clamp(1.0625rem, 2vw, 1.25rem);
  border-bottom-style: dashed;
}

.content-body h4 {
  font-size: 1rem;
  font-weight: var(--font-weight-semibold);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.content-body p {
  font-size: 1rem;
  line-height: 1.75;
  margin-bottom: var(--space-3);
  color: var(--color-fg);
}

.content-body ul,
.content-body ol {
  margin-bottom: var(--space-3);
  padding-left: var(--space-4);
}

.content-body ul {
  list-style: disc;
}

.content-body ol {
  list-style: decimal;
}

.content-body li {
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: var(--space-1);
}

.content-body a {
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: var(--font-weight-medium);
  transition: opacity var(--transition-base);
}

.content-body a:hover {
  opacity: 0.65;
}

.content-body strong {
  font-weight: var(--font-weight-semibold);
}

.content-body em {
  font-style: italic;
}

.content-body blockquote {
  border-left: 3px solid var(--color-fg);
  padding: var(--space-2) var(--space-3);
  margin: var(--space-4) 0;
  background: var(--color-surface);
  font-size: 0.9375rem;
  color: var(--color-muted);
}

.content-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
  font-size: 0.9375rem;
}

.content-body th,
.content-body td {
  padding: var(--space-2) var(--space-2);
  border: 1px solid var(--color-border);
  text-align: left;
}

.content-body th {
  font-weight: var(--font-weight-semibold);
  background: var(--color-surface);
}

.content-body div {
  margin-bottom: var(--space-8);
}

.content-body div:first-child {
  margin-top: 0;
}

.content-body .card,
.content-body [class*="card"] {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

/* =============================================
   H2 > SPAN DECORATION (structural requirement)
   ============================================= */

.content-body h2 > span,
.content-body h3 > span {
  display: inline;
}

/* =============================================
   FOOTER
   ============================================= */

.site-footer {
  background: var(--color-fg);
  color: var(--color-bg);
  border-top: 1px solid var(--color-fg);
}

.footer-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-6);
  align-items: start;
  padding: var(--space-6) var(--space-8);
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.footer-brand-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer-brand-name {
  font-size: 1.125rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.03em;
}

.footer-tagline {
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.55);
  max-width: 320px;
  line-height: 1.5;
}

.footer-nav-block {
  padding-top: var(--space-1);
}

.footer-nav-block dl {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-nav-block dt a,
.footer-nav-block dd a {
  font-size: 0.8125rem;
  font-weight: var(--font-weight-medium);
  color: rgba(255,255,255,0.7);
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 2px 0;
  transition: color var(--transition-base);
  white-space: nowrap;
}

.footer-nav-block dt a:hover,
.footer-nav-block dt a:focus-visible,
.footer-nav-block dd a:hover,
.footer-nav-block dd a:focus-visible {
  color: var(--color-bg);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-8);
  flex-wrap: wrap;
}

.footer-address ul {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.footer-address li {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

.footer-address li a {
  color: rgba(255,255,255,0.6);
  transition: color var(--transition-base);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.footer-address li a:hover {
  color: var(--color-bg);
}

.footer-links-list {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.footer-links-list li a {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: color var(--transition-base);
}

.footer-links-list li a:hover {
  color: var(--color-bg);
}

.footer-copy {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
  line-height: 1.5;
}

/* =============================================
   SCROLL REVEAL ANIMATIONS
   ============================================= */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(20px);
    transition:
      opacity var(--transition-reveal),
      transform var(--transition-reveal);
  }

  .reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
  }

  .reveal-stagger > * {
    opacity: 0;
    transform: translateY(16px);
    transition:
      opacity var(--transition-reveal),
      transform var(--transition-reveal);
  }

  .reveal-stagger.is-visible > *:nth-child(1) { opacity: 1; transform: none; transition-delay: 0ms; }
  .reveal-stagger.is-visible > *:nth-child(2) { opacity: 1; transform: none; transition-delay: 80ms; }
  .reveal-stagger.is-visible > *:nth-child(3) { opacity: 1; transform: none; transition-delay: 160ms; }
  .reveal-stagger.is-visible > *:nth-child(4) { opacity: 1; transform: none; transition-delay: 240ms; }
  .reveal-stagger.is-visible > *:nth-child(5) { opacity: 1; transform: none; transition-delay: 320ms; }
  .reveal-stagger.is-visible > *:nth-child(6) { opacity: 1; transform: none; transition-delay: 400ms; }
  .reveal-stagger.is-visible > *:nth-child(7) { opacity: 1; transform: none; transition-delay: 480ms; }
}

/* =============================================
   FOCUS VISIBLE
   ============================================= */

:focus-visible {
  outline: 2px solid var(--color-fg);
  outline-offset: 3px;
}

.site-header :focus-visible,
.site-footer :focus-visible {
  outline-color: var(--color-bg);
}

/* =============================================
   RESPONSIVE — TABLET (≤1024px)
   ============================================= */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 180px;
  }

  .hero-section {
    padding: var(--space-6) var(--space-4) var(--space-6);
  }

  .content-section {
    padding: var(--space-6) var(--space-4);
  }

  .footer-top {
    padding: var(--space-6) var(--space-4);
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .footer-nav-block dl {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0 var(--space-3);
  }

  .footer-bottom {
    padding: var(--space-3) var(--space-4);
  }
}

/* =============================================
   RESPONSIVE — MOBILE (≤768px)
   ============================================= */

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .site-header {
    grid-template-columns: auto 1fr auto auto;
    padding: 0 var(--space-2);
    gap: var(--space-1);
  }

  .header-nav {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--color-fg);
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-2) var(--space-3) var(--space-3);
    border-bottom: 1px solid rgba(255,255,255,0.15);
    z-index: 99;
  }

  .header-nav.is-open {
    display: flex;
  }

  .header-nav-link {
    opacity: 1;
    padding: 0 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 48px;
    font-size: 0.9375rem;
  }

  .header-nav-link:last-child {
    border-bottom: none;
  }

  .nav-toggle {
    display: flex;
  }

  .layout-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .hero-section {
    min-height: 45vh;
    padding: var(--space-6) var(--space-3) var(--space-6);
    align-items: flex-end;
  }

  .hero-h1 {
    font-size: clamp(1.75rem, 8vw, 2.5rem);
  }

  .hero-actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    justify-content: center;
    width: 100%;
    max-width: 320px;
  }

  .content-section {
    padding: var(--space-5) var(--space-3);
  }

  .content-body h2 {
    font-size: 1.25rem;
    margin-top: var(--space-6);
  }

  .footer-top {
    padding: var(--space-5) var(--space-3);
    grid-template-columns: 1fr;
  }

  .footer-nav-block dl {
    flex-direction: column;
    gap: 2px;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .footer-address ul {
    flex-direction: column;
    gap: var(--space-1);
  }

  .footer-links-list {
    flex-direction: column;
    gap: 2px;
  }
}

/* =============================================
   RESPONSIVE — SMALL MOBILE (≤375px)
   ============================================= */

@media (max-width: 375px) {
  .site-header {
    padding: 0 var(--space-2);
  }

  .logo-text {
    font-size: 1rem;
  }

  .hero-section {
    padding: var(--space-5) var(--space-2) var(--space-5);
  }

  .content-section {
    padding: var(--space-4) var(--space-2);
  }
}
