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

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #6366f1;
  --primary-light: #e0e7ff;
  --safe: #10b981;
  --safe-light: #d1fae5;
  --safe-bg: #ecfdf5;
  --warn: #f59e0b;
  --warn-light: #fef3c7;
  --warn-bg: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --info-bg: #eff6ff;
  --mobile: #8b5cf6;
  --mobile-light: #ede9fe;
  --webapp: #3b82f6;
  --webapp-light: #dbeafe;
  --api: #10b981;
  --api-light: #d1fae5;
  --cli: #f97316;
  --cli-light: #ffedd5;
  --library: #ec4899;
  --library-light: #fce7f3;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.06);
}

html { font-size: 17px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.container { max-width: 860px; margin: 0 auto; padding: 0 1.5rem; }

/* ===== Nav ===== */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; color: var(--text); }
.nav-links {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  list-style: none;
}
.nav-links li { list-style: none; }
.nav-links a {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.15s;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--primary); text-decoration: none; }
.nav-links a.active { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 3.5rem 0 2.5rem;
}
.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
}
.hero .subtitle {
  font-size: 1.08rem;
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto;
}

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}
.card-grid.three-col {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.card a:focus-visible, .card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius);
}
.card.mobile { border-color: var(--mobile); }
.card.webapp { border-color: var(--webapp); }
.card.api { border-color: var(--api); }
.card.cli { border-color: var(--cli); }
.card.library { border-color: var(--library); }

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 1.4rem;
}
.card-icon.purple { background: var(--mobile-light); color: var(--mobile); }
.card-icon.blue { background: var(--webapp-light); color: var(--webapp); }
.card-icon.green { background: var(--api-light); color: var(--api); }
.card-icon.orange { background: var(--cli-light); color: var(--cli); }
.card-icon.pink { background: var(--library-light); color: var(--library); }

.card h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.5rem; }
.card p { color: var(--text-muted); margin-bottom: 1rem; flex: 1; font-size: 0.92rem; }
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: auto;
}

/* ===== Layer Stack ===== */
.layer-stack {
  margin: 2rem 0;
}
.layer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.layer > summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.layer > summary::-webkit-details-marker { display: none; }
.layer[open] > summary {
  border-bottom: 1px solid var(--border);
}
.layer-body {
  padding: 1.5rem;
}
.layer-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.layer-title {
  font-size: 1.05rem;
  font-weight: 700;
  flex: 1;
}
.layer-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-left: auto;
}
.layer-badge.has-obligation {
  background: #fef3c7;
  color: #92400e;
}
.layer-badge.no-obligation {
  background: #e2e8f0;
  color: #475569;
}
.layer-chevron {
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.layer[open] .layer-chevron {
  transform: rotate(90deg);
}
.layer p { margin-bottom: 0.5rem; }
.layer p:last-child { margin-bottom: 0; }

/* ===== Verdict Boxes (kept for backward compat) ===== */
.verdict {
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
  border-left: 4px solid;
}
.verdict.safe, .verdict.verdict-safe { background: var(--safe-bg); border-color: var(--safe); }
.verdict.warn, .verdict.verdict-warn { background: var(--warn-bg); border-color: var(--warn); }
.verdict.danger, .verdict.verdict-danger { background: var(--danger-bg); border-color: var(--danger); }
.verdict.info, .verdict.verdict-info { background: var(--info-bg); border-color: var(--info); }

.verdict-label {
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}
.verdict.safe .verdict-label, .verdict.verdict-safe .verdict-label { color: var(--safe); }
.verdict.warn .verdict-label, .verdict.verdict-warn .verdict-label { color: var(--warn); }
.verdict.danger .verdict-label, .verdict.verdict-danger .verdict-label { color: var(--danger); }
.verdict.info .verdict-label, .verdict.verdict-info .verdict-label { color: var(--info); }

/* ===== Permissions / Conditions / Limitations ===== */
.pcl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}
.pcl-col h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid;
}
.pcl-col.permissions h4 { color: var(--safe); border-color: var(--safe); }
.pcl-col.conditions h4 { color: var(--info); border-color: var(--info); }
.pcl-col.limitations h4 { color: var(--danger); border-color: var(--danger); }

.pcl-col ul {
  list-style: none;
  padding: 0;
}
.pcl-col li {
  font-size: 0.88rem;
  padding: 0.3rem 0;
  padding-left: 1.2rem;
  position: relative;
  line-height: 1.5;
}
.pcl-col li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.pcl-col.permissions li::before { background: var(--safe); }
.pcl-col.conditions li::before { background: var(--info); }
.pcl-col.limitations li::before { background: var(--danger); }

/* ===== Obligation Box ===== */
.obligation {
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
  border-left: 4px solid var(--border);
  background: var(--surface);
  border-color: var(--info);
  background: var(--info-bg);
}
.obligation-label {
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
  color: var(--info);
}
.obligation.action { border-color: var(--safe); background: var(--safe-bg); }
.obligation.action .obligation-label { color: var(--safe); }
.obligation.note { border-color: var(--text-muted); background: #f1f5f9; }
.obligation.note .obligation-label { color: var(--text-muted); }

/* ===== Key Rule ===== */
.key-rule {
  background: linear-gradient(135deg, var(--primary-light), #f0f0ff);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 2rem 0;
  text-align: center;
}
.key-rule h3 { font-size: 1.05rem; color: var(--primary); margin: 0 0 0.5rem; }
.key-rule p { font-size: 1rem; max-width: 600px; margin: 0 auto; }

/* ===== Analogy ===== */
.analogy {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 0.93rem;
}
.analogy strong { color: var(--primary); }

/* ===== Reference Table ===== */
.ref-table, table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5rem 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.ref-table th, .ref-table td,
table th, table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.ref-table th, table th {
  background: #f1f5f9;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.ref-table tr:last-child td, table tr:last-child td { border-bottom: none; }
.safe-text { color: var(--safe); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
.danger-text { color: var(--danger); font-weight: 600; }

/* ===== Section ===== */
section { padding: 2rem 0; }
section h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.75rem; }
section h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; margin-top: 1.25rem; }
section p + p { margin-top: 0.75rem; }

/* ===== Breadcrumb ===== */
.breadcrumb { padding: 1rem 0 0; font-size: 0.86rem; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ===== Page Header ===== */
.page-header { padding: 2rem 0 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.8rem; font-weight: 800; }
.page-header .lead { font-size: 1.02rem; color: var(--text-muted); margin-top: 0.5rem; }

/* ===== Product Obligations (How to Fulfill) ===== */
.product-obligations {
  margin-top: 3rem;
  padding-top: 0.5rem;
}
.product-obligations h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 0.6rem;
}
.product-obligations h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 2.5rem 0 0;
}
.product-obligations hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0 1.1rem;
}
.product-obligations p {
  margin-bottom: 0.85rem;
  line-height: 1.7;
}
.product-obligations ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin: 0.5rem 0 1rem;
}
.product-obligations ul li {
  margin-bottom: 0.45rem;
  line-height: 1.65;
}

/* ===== Footer ===== */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 3rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

footer .footer-meta {
  margin-top: 0.5rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

/* ===== Responsive ===== */
@media (max-width: 640px) {
  html { font-size: 16px; }
  .hero h1 { font-size: 1.7rem; }
  .card-grid { grid-template-columns: 1fr; }
  .ref-table { font-size: 0.82rem; }
  .ref-table th, .ref-table td { padding: 0.5rem 0.6rem; }
  nav .container { flex-wrap: nowrap; }
  .nav-links {
    gap: 0.6rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }
}
