/* ═══════════════════════════════════════════════════════════
   Glass Bead Game — Shared Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --bg: #f6f4ee; --bg-alt: #eceae3; --fg: #26241e; --fg-soft: #5e5243;
  --fg-muted: #7c6e5c; --surface: #fffcf5; --border: #ded2bc;
  --accent: #b08c2e; --accent-soft: #b08c2e18; --accent-hover: #96760f;
  --link: #8a5a48;
  --d0: #4a78b0; --d1: #388888; --d2: #7a5898; --d3: #ac5470;
  --d4: #98782a; --d5: #56884a; --d6: #5c6c7e; --d7: #9c6636;
  --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Sans 3', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #14131a; --bg-alt: #1c1b24; --fg: #e2e0d9; --fg-soft: #b0ada5;
  --fg-muted: #908d83; --surface: #211f28; --border: #38363f;
  --accent: #d4a93e; --accent-soft: #d4a93e12; --accent-hover: #e8c05a;
  --link: #c89050;
  --d0: #6a98d0; --d1: #58abab; --d2: #9878b6; --d3: #cc7490;
  --d4: #b89e48; --d5: #76a866; --d6: #7e8ea2; --d7: #bc8656;
  --shadow: 0 2px 12px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131a; --bg-alt: #1c1b24; --fg: #e2e0d9; --fg-soft: #b0ada5;
    --fg-muted: #908d83; --surface: #211f28; --border: #38363f;
    --accent: #d4a93e; --accent-soft: #d4a93e12; --accent-hover: #e8c05a;
    --link: #c89050;
    --d0: #6a98d0; --d1: #58abab; --d2: #9878b6; --d3: #cc7490;
    --d4: #b89e48; --d5: #76a866; --d6: #7e8ea2; --d7: #bc8656;
    --shadow: 0 2px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    color-scheme: dark;
  }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.65 var(--font-body); -webkit-font-smoothing: antialiased }
img { max-width: 100%; display: block }
a { color: var(--link); transition: color 0.15s }
a:hover { color: var(--accent-hover) }

/* ── Site Header ── */
.site-header {
  border-bottom: 1px solid var(--border); background: var(--bg-alt);
  position: sticky; top: 0; z-index: 100; backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.site-header .inner {
  max-width: 1100px; margin: 0 auto; display: flex; align-items: center;
  flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px;
}
.site-mast {
  font-family: var(--font-display); font-size: 1.3rem;
  text-decoration: none; color: var(--fg); white-space: nowrap;
}
.site-mast em { color: var(--accent) }

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center;
  font-size: 0.82rem; color: var(--fg-muted); margin-left: auto;
}
.breadcrumb a { color: var(--fg-muted); text-decoration: none }
.breadcrumb a:hover { color: var(--accent) }
.breadcrumb .sep { margin: 0 0.15rem; opacity: 0.5 }
.breadcrumb .current { color: var(--accent); font-weight: 600 }

/* ═══ "Grail Path" theme — header line ═══════════════════════
   Top header words share one face (family, size, weight). Only the
   links off the page (HOME / PHILOSOPHY) are in caps; the current page
   name and the Chimes / Dark controls keep their normal case. The .site-mast "alkhemy.com" is untouched.
   (Rules appear after the base .breadcrumb/.ctrl-btn rules below.) */

/* ── Controls (theme, sound) ── */
.controls {
  display: flex; gap: 8px; align-items: center; margin-left: 12px;
}
.ctrl-btn {
  background: none; border: 1.5px solid var(--border); border-radius: 100px;
  padding: 5px 10px; font-size: 0.72rem; color: var(--fg-muted);
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 4px;
  font-family: var(--font-body); white-space: nowrap;
  min-height: 36px;
}
.ctrl-btn:hover { border-color: var(--accent); color: var(--accent) }
.ctrl-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft) }
.ctrl-btn svg { width: 14px; height: 14px; fill: currentColor }

@media (max-width: 600px) {
  .site-header .inner { padding: 8px 12px; gap: 6px 10px }
  .site-mast { font-size: 1.1rem }
  .breadcrumb { font-size: 0.75rem; order: 3; width: 100%; margin-left: 0 }
  .controls { margin-left: auto; gap: 6px }
  .ctrl-btn { padding: 6px 10px; font-size: 0.7rem; min-height: 36px }
}

/* ── Banner ── */
.banner {
  position: relative; overflow: hidden;
  padding: 72px 24px 60px; text-align: center;
  background: var(--bg-alt);
}
.banner-bg {
  position: absolute; inset: 0; opacity: 0.12;
  background-size: cover; background-position: center;
  pointer-events: none;
}
[data-theme="dark"] .banner-bg { opacity: 0.08 }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner-bg { opacity: 0.08 } }
.banner-content { position: relative; z-index: 1; max-width: 800px; margin: 0 auto }
.banner h1 {
  font-family: var(--font-display); font-size: clamp(1.8rem, 5vw, 3.4rem);
  font-weight: 700; line-height: 1.08; margin: 0 0 0.3em;
  color: var(--accent); letter-spacing: 0.01em;
}
.banner .subtitle {
  font-family: var(--font-display); font-size: clamp(0.92rem, 2vw, 1.2rem);
  font-style: italic; color: var(--fg-soft); line-height: 1.5;
  margin: 0 0 0.6em; max-width: 650px; margin-inline: auto;
}
.banner .dedication {
  font-size: 0.82rem; color: var(--fg-muted); margin: 0;
  font-style: italic;
}
@media (max-width: 600px) {
  .banner { padding: 28px 16px 22px !important }
  .banner .dedication { font-size: 0.76rem }
}

/* ── Main Layout (sidebar + content) ── */
.page-layout {
  max-width: 1100px; margin: 0 auto; padding: 2rem 24px 4rem;
  display: grid; grid-template-columns: 1fr 4fr; gap: 2rem;
}
@media (max-width: 768px) {
  .page-layout { grid-template-columns: 1fr; padding: 1rem 16px 3rem }
}

/* ── Sidebar ── */
.sidebar {
  position: sticky; top: 72px; align-self: start;
  max-height: calc(100vh - 90px); overflow-y: auto;
  padding-right: 8px;
}
.sidebar::-webkit-scrollbar { width: 4px }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px }
.sidebar h3 {
  font-family: var(--font-display); font-size: 0.88rem;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--fg-muted); font-weight: 600; margin: 0 0 12px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.thumb-list { list-style: none; padding: 0; margin: 0 }
.thumb-list li { margin-bottom: 10px }
.thumb-list a {
  display: block; border-radius: var(--radius-sm); overflow: hidden;
  border: 2px solid transparent; transition: border-color 0.2s, transform 0.2s;
  text-decoration: none;
}
.thumb-list a:hover { border-color: var(--accent); transform: translateY(-2px) }
.thumb-list a.active { border-color: var(--accent) }
.thumb-img {
  width: 100%; aspect-ratio: 16/10; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; color: var(--fg-muted); overflow: hidden;
  position: relative;
}
.thumb-img svg { width: 100%; height: 100% }
.thumb-label {
  display: block; padding: 6px 8px; font-size: 0.74rem;
  font-weight: 600; color: var(--fg); background: var(--surface);
  line-height: 1.3;
}

@media (max-width: 768px) {
  .sidebar {
    position: static; max-height: none; overflow: visible;
    padding-right: 0; margin: 0 -16px; padding: 0 16px;
  }
  .sidebar h3 { font-size: 0.78rem; margin-bottom: 8px }
  .thumb-list {
    display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    padding-bottom: 8px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  }
  .thumb-list::-webkit-scrollbar { height: 3px }
  .thumb-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px }
  .thumb-list li {
    flex: 0 0 120px; margin-bottom: 0; scroll-snap-align: start;
  }
  .thumb-list a:hover { transform: none }
  .thumb-img { aspect-ratio: 4/3 }
  .thumb-label { font-size: 0.7rem; padding: 4px 6px }
}

/* ── Content Area ── */
.content h2 {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 700;
  color: var(--accent); margin: 2.5rem 0 0.6rem;
  padding-bottom: 6px; border-bottom: 1.5px solid var(--border);
}
.content h2:first-child { margin-top: 0 }
.content h3 { font-size: 1rem; font-weight: 700; margin: 1.4rem 0 0.3rem }
.content p { margin: 0 0 0.75rem }
.content ul, .content ol { padding-left: 1.3rem; margin: 0 0 0.75rem }
.content li { margin-bottom: 0.3rem }

/* ── Cards ── */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px; margin: 1.5rem 0;
}
.card {
  display: block; padding: 24px; background: var(--surface);
  border: 1px solid var(--border); border-left: 5px solid var(--accent);
  border-radius: var(--radius); text-decoration: none; color: var(--fg);
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg) }
.card h3 {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 600;
  margin: 0 0 0.15em; color: var(--dc, var(--accent)); line-height: 1.15;
}
.card p { color: var(--fg-soft); font-size: 0.92rem; margin: 0 0 0.75em }
.card .go {
  font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--dc, var(--accent)); font-weight: 600;
}
@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr !important; gap: 12px }
  .card { padding: 16px }
  .card h3 { font-size: 1.2rem }
  .card:hover { transform: none }
}

/* ── Domain Tags ── */
.domain-tag {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 0.15em 0.5em; border-radius: 100px;
  border: 1.5px solid; white-space: nowrap; line-height: 1.4;
}

/* ── Featured Box ── */
.featured {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.featured-header {
  padding: 16px 24px; background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.featured-header h3 {
  font-family: var(--font-display); font-size: 1.1rem;
  font-weight: 600; margin: 0; color: var(--accent);
}
.featured-header .badge {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 100px; padding: 0.15em 0.6em;
}
.featured-body { padding: 24px }
.featured-body p { font-size: 0.9rem; margin: 0 0 0.75rem }
.featured-body .launch-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; background: var(--accent); color: #fff;
  border: none; border-radius: 100px; font-size: 0.92rem;
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font-body); min-height: 44px;
}
.featured-body .launch-btn:hover { background: var(--accent-hover); color: #fff }
@media (max-width: 600px) {
  .featured-header { padding: 12px 16px }
  .featured-body { padding: 16px }
  .featured-body .launch-btn { width: 100%; justify-content: center }
}

/* ── Timeline ── */
.timeline { position: relative; padding-left: 32px; margin: 2rem 0 }
.timeline::before {
  content: ''; position: absolute; left: 12px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; margin-bottom: 2rem }
.tl-item::before {
  content: ''; position: absolute; left: -26px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
}
.tl-date {
  font-size: 0.75rem; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 0.2rem;
}
.tl-title { font-size: 1rem; font-weight: 700; margin: 0 0 0.25rem }
.tl-desc { font-size: 0.88rem; color: var(--fg-soft); margin: 0 }

/* ── Skill Domain Section ── */
.domain-section { margin-bottom: 2.5rem; scroll-margin-top: 80px }
.domain-head {
  display: flex; align-items: baseline; gap: 0.6rem;
  border-bottom: 2px solid var(--dc); padding-bottom: 0.35rem;
  margin-bottom: 0.75rem;
}
.domain-head h2 {
  font-family: var(--font-display); font-size: 1.3rem;
  font-weight: 700; margin: 0; color: var(--dc); border: none; padding: 0;
}
.domain-head .dtag {
  font-size: 0.78rem; color: var(--fg-muted); font-style: italic;
}

.skill-card {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 0.85rem 1rem; margin-bottom: 0.6rem;
  border-left: 3px solid var(--dc, var(--accent));
}
.skill-card h3 { font-size: 0.95rem; font-weight: 700; margin: 0 0 0.15rem; color: var(--dc, var(--accent)) }
.skill-card .plain {
  font-size: 0.84rem; font-style: italic; color: var(--accent);
  margin: 0 0 0.35rem; line-height: 1.4;
}
.skill-card .formal { font-size: 0.82rem; line-height: 1.55; margin: 0 0 0.35rem; color: var(--fg-soft) }
.skill-card .links { display: flex; flex-wrap: wrap; gap: 0.25rem }
.skill-card .links span {
  font-size: 0.7rem; padding: 0.1em 0.4em; border-radius: 100px;
  border: 1px solid var(--border); color: var(--fg-muted); white-space: nowrap;
}

/* ── Footer ── */
.site-footer {
  margin-top: 4rem; border-top: 1px solid var(--border);
  background: var(--bg-alt); padding: 28px 24px 42px; text-align: center;
}
.site-footer p { font-size: 0.84rem; color: var(--fg-muted); margin: 0 0 0.3rem }
.site-footer a { color: var(--fg-muted) }
.site-footer a:hover { color: var(--accent) }
@media (max-width: 600px) {
  .site-footer { margin-top: 2rem; padding: 20px 16px 32px }
}

/* ── Print ── */
@media print {
  .site-header, .site-footer, .controls, .sidebar, .banner-bg { display: none !important }
  body { background: #fff; color: #000; font-size: 11pt }
  .page-layout { display: block; padding: 0 }
  .banner { background: none; padding: 24px 0; border-bottom: 2px solid #000 }
  .banner h1 { color: #000 }
  .card, .skill-card, .featured { break-inside: avoid }
  a { color: #000; text-decoration: underline }
}

/* ── Utility ── */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.text-accent { color: var(--accent) }
.text-muted { color: var(--fg-muted) }
.mt-0 { margin-top: 0 }
.mb-0 { margin-bottom: 0 }

/* ── Global Mobile ── */
@media (max-width: 600px) {
  body { font-size: 16px; line-height: 1.6 }
  .content h2 { font-size: 1.15rem; margin-top: 1.75rem }
  .skill-card { padding: 0.7rem 0.8rem }
  .skill-card h3 { font-size: 0.9rem }
  .skill-card .plain { font-size: 0.82rem }
  .skill-card .formal { font-size: 0.8rem }
}

/* ── Glass beads (v1.2) — rendered after the Castalia plates: deep body, lit core, caustic, specular ── */
.glass-bead, .skill-card h3::before, .game-wrap .bead::before {
  display: inline-block; border-radius: 50%; flex-shrink: 0;
  background:
    radial-gradient(circle at 33% 27%, rgba(255,255,255,.95) 0 7%, rgba(255,255,255,.45) 12%, rgba(255,255,255,0) 24%),
    radial-gradient(ellipse 58% 30% at 50% 80%, color-mix(in srgb, var(--bc) 30%, #fff) 0, rgba(255,255,255,0) 72%),
    radial-gradient(circle at 42% 38%, color-mix(in srgb, var(--bc) 50%, #fff) 0, var(--bc) 55%, color-mix(in srgb, var(--bc) 45%, #000) 100%);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--bc) 55%, #000),
    0 2px 7px color-mix(in srgb, var(--bc) 45%, transparent);
}
.glass-bead { --bc: var(--accent) }
.skill-card { --bc: var(--dc, var(--accent)) }
.skill-card h3::before { content: ''; width: .78em; height: .78em; margin-right: .42em; vertical-align: -.06em }
.game-wrap .bead { flex-direction: column; gap: 6px }
.game-wrap .bead::before { content: ''; width: 18px; height: 18px; transition: transform .2s }
.game-wrap .bead.played::before { transform: scale(1.25) }
.sb-domains .dom-pip.glass-bead.active { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bc) 55%, #000), 0 0 9px var(--bc) }
.dom-dot.glass-bead { width: 15px !important; height: 15px !important }
.domain-disclosure summary:hover .glass-bead { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bc) 55%, #000), 0 0 12px color-mix(in srgb, var(--bc) 70%, transparent) }

/* Index banner — the Castalia poster, subdued beneath the title */
.banner-bg.banner-castalia { background-size: cover; background-position: center 42%; opacity: .17; filter: saturate(.8) }
.banner:has(.banner-castalia) .banner-content::before { content: ''; position: absolute; inset: -18px -40px; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, var(--bg-alt) 35%, transparent); opacity: .85 }
[data-theme="dark"] .banner-bg.banner-castalia { opacity: .16; filter: saturate(.7) brightness(.85) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner-bg.banner-castalia { opacity: .16; filter: saturate(.7) brightness(.85) } }

/* Wind-chime tuning selector beside the sound button (v1.5) */
select.chime-tuning { appearance:none; -webkit-appearance:none; cursor:pointer; font:inherit; font-size:.78rem; max-width:13rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
@media (max-width:640px) { select.chime-tuning { max-width:8.5rem } }
select.chime-tuning option { color:#222; background:#fff }

/* ═══ "Grail Path" theme — header line overrides ═══ */
.site-header .breadcrumb,
.site-header .breadcrumb a,
.site-header .breadcrumb .current,
.site-header .ctrl-btn {
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
}
/* Caps only for the links that lead off the page (HOME / PHILOSOPHY);
   the current page name and the on-page controls keep their own case. */
.site-header .breadcrumb a { text-transform: uppercase; letter-spacing: 0.08em }
@media (max-width: 600px) {
  .site-header .breadcrumb,
  .site-header .breadcrumb a,
  .site-header .breadcrumb .current,
  .site-header .ctrl-btn { font-size: 0.7rem }
  .site-header .breadcrumb a { letter-spacing: 0.06em }
}
