/* ============================================================
   DESIGNPEDIA — stylesheet
   A visual encyclopedia of design terminology.
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  /* Light theme palette */
  --bg: #f7f5f1;
  --bg-elevated: #fffdfa;
  --bg-sunken: #efece5;
  --surface: #ffffff;
  --ink: #1b1a17;
  --ink-soft: #514d45;
  --ink-faint: #8a8479;
  --line: #e4e0d7;
  --line-strong: #d3cec3;
  --accent: #5b4bff;
  --accent-soft: #ece9ff;
  --accent-ink: #3f30d6;
  --gold: #c8892b;
  --shadow-sm: 0 1px 2px rgba(30, 25, 15, .06), 0 1px 3px rgba(30, 25, 15, .05);
  --shadow-md: 0 4px 12px rgba(30, 25, 15, .08), 0 2px 4px rgba(30, 25, 15, .05);
  --shadow-lg: 0 18px 48px rgba(28, 22, 10, .16), 0 6px 16px rgba(28, 22, 10, .10);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;

  /* Domain accent hues (h s l) */
  --d-overlays: 262 83% 63%;
  --d-nav: 199 89% 48%;
  --d-typography: 340 75% 55%;
  --d-color: 25 90% 55%;
  --d-layout: 152 55% 42%;
  --d-print: 45 85% 45%;
  --d-ux: 280 60% 55%;

  --maxw: 1280px;
}

[data-theme="dark"] {
  --bg: #14130f;
  --bg-elevated: #1c1a15;
  --bg-sunken: #100f0c;
  --surface: #201d17;
  --ink: #f3efe6;
  --ink-soft: #c3bdb0;
  --ink-faint: #8b857a;
  --line: #322e26;
  --line-strong: #423d33;
  --accent: #8f83ff;
  --accent-soft: #241f4a;
  --accent-ink: #b3aaff;
  --gold: #e0a63f;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.6), 0 8px 20px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  transition: background .4s ease, color .4s ease;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--accent-ink); text-decoration: none; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* subtle grain / texture on background */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: radial-gradient(circle at 15% 20%, hsla(262,83%,63%,.05), transparent 40%),
                    radial-gradient(circle at 85% 15%, hsla(25,90%,55%,.05), transparent 40%),
                    radial-gradient(circle at 70% 90%, hsla(152,55%,42%,.05), transparent 45%);
  pointer-events: none; z-index: 0;
}

/* ============================================================
   HEADER
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), hsl(25 90% 55%));
  display: grid; place-items: center; color: #fff; font-weight: 800;
  font-family: var(--font-display); font-size: 20px; box-shadow: var(--shadow-sm);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.brand:hover .mark { transform: rotate(-8deg) scale(1.06); }
.brand .wordmark { font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: -.02em; }
.brand .wordmark b { color: var(--accent-ink); font-weight: 600; }

.search {
  flex: 1; max-width: 520px; position: relative; margin: 0 auto;
}
.search input {
  width: 100%; font-size: 15px; padding: 11px 40px 11px 42px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--bg-elevated); color: var(--ink); outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); pointer-events: none; }
.search .kbd {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 6px; background: var(--bg-sunken);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.btn-icon {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--bg-elevated); color: var(--ink-soft);
  transition: all .2s;
}
.btn-icon:hover { color: var(--accent-ink); border-color: var(--accent); transform: translateY(-1px); }
.btn-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-elevated); color: var(--ink-soft);
  font-size: 14px; font-weight: 500; transition: all .2s; white-space: nowrap;
}
.btn-pill:hover { color: var(--accent-ink); border-color: var(--accent); transform: translateY(-1px); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative; z-index: 1;
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(40px, 7vw, 88px) clamp(16px, 4vw, 40px) 30px;
  text-align: center;
}
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft);
  padding: 6px 14px; border-radius: 999px; margin-bottom: 22px;
}
.hero h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(40px, 8vw, 82px); line-height: .98; letter-spacing: -.03em;
  margin: 0 0 18px;
}
.hero h1 .fx { color: var(--accent-ink); font-style: italic; position: relative; }
.hero p.lead {
  font-size: clamp(16px, 2.2vw, 21px); color: var(--ink-soft);
  max-width: 640px; margin: 0 auto 30px; line-height: 1.5;
}
.hero-stats { display: flex; gap: 30px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.hero-stats .stat { text-align: center; }
.hero-stats .num { font-family: var(--font-display); font-size: 34px; font-weight: 600; color: var(--ink); line-height: 1; }
.hero-stats .lbl { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-top: 6px; }

/* domain quick-jump chips */
.domain-jump { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 34px; }
.domain-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 15px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--bg-elevated); font-size: 14px; font-weight: 500;
  color: var(--ink-soft); transition: all .2s;
}
.domain-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: hsl(var(--h)); }
.domain-chip:hover { transform: translateY(-2px); border-color: hsl(var(--h)); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ============================================================
   LAYOUT
   ============================================================ */
.shell {
  position: relative; z-index: 1;
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px) 80px;
  display: grid; grid-template-columns: 244px 1fr; gap: 34px;
  align-items: start;
}

/* Sidebar */
.rail { position: sticky; top: 84px; align-self: start; }
.rail h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-faint); margin: 22px 4px 10px; font-weight: 700;
}
.rail h3:first-child { margin-top: 4px; }
.filter-list { display: flex; flex-direction: column; gap: 2px; }
.filter-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px; border-radius: 10px;
  font-size: 14.5px; color: var(--ink-soft); text-align: left; width: 100%; transition: all .15s;
}
.filter-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--line-strong); }
.filter-item .count { margin-left: auto; font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.filter-item:hover { background: var(--bg-sunken); color: var(--ink); }
.filter-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.filter-item.active .count { color: var(--accent-ink); }

.rail .tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
.rail .tag-cloud button {
  font-size: 12px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink-faint); transition: all .15s;
}
.rail .tag-cloud button:hover { color: var(--accent-ink); border-color: var(--accent); }
.rail .tag-cloud button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Content */
.content { min-width: 0; }
.content-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.content-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 26px; letter-spacing: -.02em; margin: 0; }
.content-head .result-count { font-size: 14px; color: var(--ink-faint); }
.view-switch { margin-left: auto; display: flex; gap: 4px; background: var(--bg-sunken); padding: 4px; border-radius: 12px; }
.view-switch button {
  padding: 7px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--ink-soft); transition: all .18s;
}
.view-switch button.active { background: var(--bg-elevated); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Cards grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 16px; }

.card {
  position: relative; text-align: left; padding: 20px; border-radius: var(--radius);
  background: var(--bg-elevated); border: 1px solid var(--line);
  transition: transform .22s cubic-bezier(.2,.7,.3,1), box-shadow .22s, border-color .22s;
  overflow: hidden; display: flex; flex-direction: column; gap: 9px; min-height: 150px;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: hsl(var(--h)); opacity: .8; transition: width .22s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: hsl(var(--h) / .5); }
.card:hover::before { width: 7px; }
.card .card-cat {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: hsl(var(--h)); display: inline-flex; align-items: center; gap: 6px;
}
.card h4 { font-size: 18.5px; font-weight: 650; margin: 0; letter-spacing: -.01em; font-family: var(--font-display); }
.card .card-short { font-size: 14px; color: var(--ink-soft); line-height: 1.45; margin: 0; flex: 1; }
.card .card-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.card .badge-confuse {
  font-size: 11px; font-weight: 600; color: var(--gold);
  display: inline-flex; align-items: center; gap: 4px;
}
.card .badge-demo {
  font-size: 11px; font-weight: 600; color: var(--accent-ink);
  display: inline-flex; align-items: center; gap: 4px;
}
mark { background: hsla(45,90%,55%,.4); color: inherit; border-radius: 3px; padding: 0 2px; }
[data-theme="dark"] mark { background: hsla(45,90%,55%,.28); }

/* Empty state */
.empty { text-align: center; padding: 80px 20px; color: var(--ink-faint); }
.empty .big { font-size: 44px; margin-bottom: 12px; }

/* ============================================================
   CONFUSABLES VIEW
   ============================================================ */
.confusables { display: flex; flex-direction: column; gap: 22px; }
.confuse-intro { font-size: 15px; color: var(--ink-soft); max-width: 640px; line-height: 1.55; }
.confuse-card {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-elevated);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.confuse-card .ch-head {
  padding: 16px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; background: var(--bg-sunken);
}
.confuse-card .ch-head .vs {
  font-family: var(--font-display); font-style: italic; color: var(--gold); font-weight: 600; font-size: 15px;
}
.confuse-card .ch-head h3 { font-size: 16.5px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.confuse-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.confuse-col {
  padding: 20px 22px; border-right: 1px solid var(--line);
}
.confuse-col:last-child { border-right: none; }
.confuse-col .cc-top { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.confuse-col .cc-dot { width: 11px; height: 11px; border-radius: 50%; background: hsl(var(--h)); flex: none; }
.confuse-col h4 { margin: 0; font-size: 17px; font-weight: 650; font-family: var(--font-display); cursor: pointer; }
.confuse-col h4:hover { color: var(--accent-ink); }
.confuse-col .cc-short { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 12px; line-height: 1.45; }
.confuse-col .cc-note {
  font-size: 13px; color: var(--ink); line-height: 1.5; background: var(--accent-soft);
  border-radius: 10px; padding: 10px 13px; border-left: 3px solid var(--accent);
}
.confuse-col .cc-note b { color: var(--accent-ink); }

/* ============================================================
   DETAIL DRAWER
   ============================================================ */
.scrim {
  position: fixed; inset: 0; background: rgba(15,12,6,.5); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .35s; backdrop-filter: blur(2px);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); z-index: 100;
  background: var(--bg-elevated); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .42s cubic-bezier(.16,1,.3,1);
  display: flex; flex-direction: column; border-left: 1px solid var(--line);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 22px 26px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 14px;
}
.drawer-head .d-cat {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: hsl(var(--h)); display: inline-flex; align-items: center; gap: 7px; margin-bottom: 9px;
}
.drawer-head .d-cat .dot { width: 9px; height: 9px; border-radius: 50%; background: hsl(var(--h)); }
.drawer-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 30px; letter-spacing: -.02em; margin: 0; line-height: 1.05; }
.drawer-head .d-aka { font-size: 13px; color: var(--ink-faint); margin-top: 7px; }
.drawer-body { padding: 22px 26px 40px; overflow-y: auto; flex: 1; }
.drawer-body h5 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint);
  font-weight: 700; margin: 26px 0 10px;
}
.drawer-body h5:first-child { margin-top: 0; }
.drawer-body .d-long { font-size: 15.5px; line-height: 1.62; color: var(--ink); }
.d-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.d-tags span {
  font-size: 12px; padding: 4px 11px; border-radius: 999px; background: var(--bg-sunken);
  color: var(--ink-soft); border: 1px solid var(--line);
}
.d-example {
  font-size: 14.5px; color: var(--ink); background: var(--bg-sunken); border-radius: 12px;
  padding: 13px 16px; line-height: 1.5; border-left: 3px solid var(--gold);
}
.d-confuse-note {
  font-size: 14.5px; line-height: 1.58; background: hsla(45,90%,55%,.1);
  border: 1px solid hsla(45,80%,50%,.3); border-radius: 12px; padding: 14px 16px; color: var(--ink);
}
.d-confuse-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.d-confuse-links button {
  font-size: 13.5px; font-weight: 500; padding: 7px 13px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--bg-elevated); color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 6px; transition: all .18s;
}
.d-confuse-links button:hover { border-color: var(--accent); color: var(--accent-ink); transform: translateY(-1px); }
.d-confuse-links button .dot { width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--h)); }

/* Live demo stage */
.demo-wrap { margin-top: 6px; }
.demo-stage {
  position: relative; border: 1px solid var(--line-strong); border-radius: 16px; overflow: hidden;
  background: repeating-linear-gradient(45deg, var(--bg-sunken), var(--bg-sunken) 10px, transparent 10px, transparent 20px);
  min-height: 230px; display: flex; align-items: center; justify-content: center;
}
[data-theme="dark"] .demo-stage {
  background: repeating-linear-gradient(45deg, var(--bg-sunken), var(--bg-sunken) 10px, transparent 10px, transparent 20px);
}
.demo-controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.demo-btn {
  font-size: 13.5px; font-weight: 600; padding: 9px 16px; border-radius: 10px;
  background: var(--accent); color: #fff; transition: all .18s; box-shadow: var(--shadow-sm);
}
.demo-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.demo-btn.ghost { background: var(--bg-elevated); color: var(--ink-soft); border: 1px solid var(--line-strong); }
.demo-caption { font-size: 12.5px; color: var(--ink-faint); margin-top: 9px; line-height: 1.4; }

/* generic "phone frame" for demos */
.phone {
  width: 190px; height: 210px; background: var(--surface); border-radius: 22px;
  border: 1px solid var(--line-strong); position: relative; overflow: hidden; box-shadow: var(--shadow-md);
}
.phone .status { height: 22px; display: flex; align-items: center; justify-content: center; }
.phone .status::before { content: ""; width: 46px; height: 5px; border-radius: 4px; background: var(--line-strong); }
.phone .screen { position: absolute; inset: 22px 0 0; overflow: hidden; }
.sk-line { height: 9px; border-radius: 5px; background: var(--bg-sunken); margin: 9px 14px; }
.sk-line.s { width: 45%; }
.sk-line.m { width: 70%; }

/* ============================================================
   RECENTLY VIEWED STRIP
   ============================================================ */
.recent-wrap {
  position: relative; z-index: 1;
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px) 18px;
}
.recent-wrap[hidden] { display: none; }
.recent-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); font-weight: 700; display: block; margin-bottom: 9px;
}
.recent-chips {
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
}
.recent-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg-elevated);
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft); transition: all .18s;
}
.recent-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--h)); flex: none; }
.recent-chip:hover { color: var(--ink); border-color: hsl(var(--h)); transform: translateY(-1px); }
.recent-clear {
  font-size: 12px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink-faint); margin-left: 4px; transition: all .15s;
}
.recent-clear:hover { color: var(--ink-soft); border-color: var(--line-strong); }

/* ============================================================
   DRAWER ACTIONS (copy/share buttons)
   ============================================================ */
.drawer-actions {
  display: flex; align-items: flex-start; gap: 6px; flex-shrink: 0; padding-top: 4px;
}
.drawer-close {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-sunken); color: var(--ink-soft); display: grid; place-items: center; transition: all .2s;
}
.drawer-close:hover { background: var(--accent-soft); color: var(--accent-ink); }

/* ============================================================
   FOOTER
   ============================================================ */
.foot {
  position: relative; z-index: 1; border-top: 1px solid var(--line);
  padding: 36px clamp(16px,4vw,40px); text-align: center; color: var(--ink-faint); font-size: 13.5px;
  max-width: var(--maxw); margin: 0 auto;
}
.foot b { color: var(--ink-soft); font-family: var(--font-display); }

/* ============================================================
   MOBILE
   ============================================================ */
.rail-toggle { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 95; background: var(--bg-elevated);
    padding: 20px; overflow-y: auto; transform: translateX(-100%); transition: transform .35s cubic-bezier(.16,1,.3,1);
    box-shadow: var(--shadow-lg); top: 0; border-right: 1px solid var(--line);
  }
  .rail.open { transform: translateX(0); }
  .rail-toggle { display: inline-flex; }
  .search .kbd { display: none; }
}
@media (max-width: 560px) {
  .brand .wordmark { display: none; }
  .btn-pill span.lbl { display: none; }
  .view-switch { width: 100%; margin-left: 0; }
  .view-switch button { flex: 1; }
}

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .05ms !important; }
  html { scroll-behavior: auto; }
}

/* scrollbar */
.drawer-body::-webkit-scrollbar, .rail::-webkit-scrollbar { width: 10px; }
.drawer-body::-webkit-scrollbar-thumb, .rail::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid var(--bg-elevated); }
