/* ================================================
   CSS SCROLL GUIDE
   Palette : #264653 · #2a9d8f · #e76f51 · warm neutrals
   ================================================ */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 60px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: #2b2b2b;
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

/* ---------- NAV ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #e8e8e3;
}

.nav-brand {
  font-weight: 600;
  font-size: 0.9rem;
  color: #2b2b2b;
  text-decoration: none;
  letter-spacing: -0.3px;
}

.nav-links {
  display: flex;
  gap: 1.75rem;
}

.nav-links a {
  color: #888;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.15s;
}

.nav-links a:hover {
  color: #2b2b2b;
}

/* ---------- HERO ---------- */
.hero {
  max-width: 680px;
  margin: 0 auto;
  padding: 5rem 2rem 3.5rem;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.5px;
  color: #1a1a1a;
  margin-bottom: 1rem;
}

.hero-sub {
  font-size: 1.05rem;
  color: #777;
  line-height: 1.6;
}

/* ---------- SECTIONS ---------- */
.section {
  max-width: 780px;
  margin: 0 auto;
  padding: 4.5rem 2rem;
}

.section + .section {
  border-top: 1px solid #e8e8e3;
}

.section--alt {
  background: #fafaf7;
}

.section-num {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #bbb;
  letter-spacing: 1px;
  margin-bottom: 0.35rem;
}

.section h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.65rem;
  letter-spacing: -0.3px;
}

.section-intro {
  font-size: 1rem;
  color: #666;
  max-width: 600px;
  margin-bottom: 2.5rem;
}

/* ---------- EXPLAIN BOX ---------- */
.explain-box {
  background: #fafaf7;
  border: 1px solid #e8e8e3;
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 3rem;
}

.section--alt .explain-box {
  background: #fff;
}

.explain-box h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.explain-box > p {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.explain-card {
  padding: 1.25rem;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e8e8e3;
}

.section--alt .explain-card {
  background: #fafaf7;
}

.tag {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #264653;
  color: #fff;
  margin-bottom: 0.5rem;
}

.explain-note {
  font-size: 0.85rem;
  color: #2a9d8f;
  margin-top: 0.35rem;
}

/* ---------- LAYOUT ---------- */
.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.subtitle {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 2.5rem 0 1.25rem;
  color: #1a1a1a;
}

/* ---------- CARDS ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.cards-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.card {
  background: #fff;
  border: 1px solid #e8e8e3;
  border-radius: 10px;
  padding: 1.35rem;
}

.section--alt .card {
  background: #fff;
}

.card--note {
  background: #fefcf3;
  border-color: #e8dfc0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.card h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  background: #f0f0eb;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.card p {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.4rem;
}

.card ul {
  padding-left: 1.15rem;
  font-size: 0.9rem;
  color: #666;
}

.card li {
  margin-bottom: 0.2rem;
}

/* ---------- DEF LIST ---------- */
.def-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.def-item {
  display: flex;
  gap: 0.65rem;
  font-size: 0.87rem;
  align-items: baseline;
}

.def-key {
  flex-shrink: 0;
  font-weight: 600;
  font-family: 'Fira Code', monospace;
  font-size: 0.78rem;
  background: #f0f0eb;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  color: #444;
}

/* ---------- VISUAL ALIGN ---------- */
.visual-align {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.align-box {
  flex: 1;
  position: relative;
  background: #f0f0eb;
  border-radius: 6px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.align-box span {
  font-size: 0.7rem;
  color: #888;
  font-weight: 500;
}

.align-dot {
  position: absolute;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #264653;
}

/* ---------- CODE ---------- */
code {
  font-family: 'Fira Code', monospace;
  font-size: 0.84em;
  background: #f5f5f0;
  padding: 0.12em 0.35em;
  border-radius: 4px;
  color: #444;
}

pre {
  background: #1a1a1a;
  color: #d4d4c8;
  padding: 1rem 1.15rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
  margin: 0.6rem 0;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
}

.c-comment { color: #666; }
.c-hl      { color: #2a9d8f; }
.c-val1    { color: #e76f51; }
.c-val2    { color: #2a9d8f; }

/* ---------- DEMOS ---------- */
.demo {
  background: #fafaf7;
  border: 1px solid #e8e8e3;
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.section--alt .demo {
  background: #fff;
}

.demo-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.demo h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.demo-tag {
  font-size: 0.72rem;
  background: #264653;
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
}

.demo-hint {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 0.75rem;
}

.demo-code {
  margin-top: 0.75rem;
}

.demo-code-sm {
  font-size: 0.75rem;
  margin-top: 0.4rem;
  padding: 0.5rem 0.75rem;
}

.demo-code-sm code {
  font-size: 0.75rem;
}

/* ---------- SNAP HORIZONTAL ---------- */
.snap-x-demo {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0.5rem;
  border-radius: 8px;
  background: #f0f0eb;
  scrollbar-color: #264653 #e8e8e3;
  scrollbar-width: thin;
}

.snap-slide {
  flex: 0 0 75%;
  height: 160px;
  background: var(--bg);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  scroll-snap-align: center;
}

/* ---------- SNAP VERTICAL ---------- */
.snap-y-demo {
  height: 240px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  border-radius: 8px;
  border: 1px solid #e8e8e3;
  scrollbar-color: #264653 #f0f0eb;
  scrollbar-width: thin;
}

.snap-page {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  background: var(--bg);
  scroll-snap-align: start;
}

/* ---------- COMPARISON ---------- */
.snap-x-demo.compact {
  padding: 0.4rem;
}

.snap-mandatory { scroll-snap-type: x mandatory; }
.snap-proximity { scroll-snap-type: x proximity; }

.snap-chip {
  flex: 0 0 35%;
  height: 90px;
  background: var(--bg);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  scroll-snap-align: center;
}

.compare-label {
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  color: #666;
}

/* ---------- TOGGLE ---------- */
.toggle-group {
  display: inline-flex;
  border: 1px solid #e8e8e3;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.toggle-btn {
  padding: 0.6rem 1.5rem;
  border: none;
  background: #fff;
  font-family: 'Fira Code', monospace;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  color: #999;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn:not(:last-child) {
  border-right: 1px solid #e8e8e3;
}

.toggle-btn:hover {
  color: #2b2b2b;
}

.toggle-btn.active {
  background: #264653;
  color: #fff;
}

/* ---------- BEHAVIOR DEMO ---------- */
.behavior-box {
  height: 200px;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid #e8e8e3;
  scroll-behavior: smooth;
  scrollbar-color: #264653 #f0f0eb;
  scrollbar-width: thin;
}

.behavior-page {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--fg, #2b2b2b);
  text-align: center;
  padding: 1rem;
}

.demo-link {
  color: #264653;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- CALLOUT ---------- */
.callout {
  background: #fefcf3;
  border: 1px solid #e8dfc0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 2.5rem 0;
  font-size: 0.88rem;
  color: #666;
}

.callout strong {
  color: #2b2b2b;
}

/* ---------- SCROLLBAR VISUAL ---------- */
.scrollbar-visual {
  margin-top: 1rem;
}

.sv-track {
  position: relative;
  background: #e8e8e3;
  border-radius: 6px;
  height: 44px;
  display: flex;
  align-items: center;
  padding-left: 1rem;
  font-size: 0.75rem;
  color: #888;
}

.sv-thumb {
  position: absolute;
  right: 8px;
  top: 8px;
  bottom: 8px;
  width: 140px;
  background: #264653;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #fff;
  font-weight: 500;
}

/* ---------- SCROLLBAR DEMOS ---------- */
.sb-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.sb-label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #444;
}

.sb-box {
  height: 120px;
  overflow-y: auto;
  padding: 0.85rem;
  border-radius: 8px;
  font-size: 0.84rem;
  line-height: 1.55;
  border: 1px solid #e8e8e3;
  background: #fff;
  color: #666;
}

.sb-1 { scrollbar-color: #264653 #e0e0d8; }

.sb-2 {
  background: #1a1a1a;
  color: #bbb;
  border-color: #333;
  scrollbar-color: #a0a090 #1a1a1a;
}

.sb-3 {
  scrollbar-width: thin;
  scrollbar-color: #2a9d8f #f5f5f0;
}

.sb-4 {
  scrollbar-width: none;
}

/* ---------- TABLE ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid #e8e8e3;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
}

thead th {
  background: #fafaf7;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  border-bottom: 1px solid #e8e8e3;
}

tbody td {
  border-bottom: 1px solid #f3f3ee;
}

tbody tr:last-child td {
  border-bottom: none;
}

.row-sep td {
  border-top: 2px solid #e8e8e3;
}

/* ---------- FOOTER ---------- */
.footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.8rem;
  color: #bbb;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .two-cols,
  .cards-grid,
  .cards-grid.cols-3,
  .sb-grid {
    grid-template-columns: 1fr;
  }

  .nav-links { gap: 1.25rem; }
  .snap-slide { flex: 0 0 90%; }
  .hero { padding: 3rem 1.5rem 2rem; }
  .section { padding: 3rem 1.5rem; }
  .visual-align { flex-direction: column; }
}

/* ---------- ACCESSIBILITY ---------- */
@media (prefers-reduced-motion: reduce) {
  html, .behavior-box { scroll-behavior: auto; }
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid #264653;
  outline-offset: 2px;
}

::selection {
  background: #264653;
  color: #fff;
}
