/* Velunora — visual system. See docs/05-visual-design-system.md */
:root {
  --ink: #14121c;
  --ink-2: #1c1927;
  --ink-3: #26223a;
  --cream: #efe6da;
  --cream-dim: rgba(239, 230, 218, 0.72);
  --cream-faint: rgba(239, 230, 218, 0.48);
  --apricot: #f2b69a;
  --lavender: #a99ad6;
  --sea: #7cc4c8;
  --glass: rgba(24, 21, 34, 0.62);
  --glass-line: rgba(239, 230, 218, 0.12);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 18px;
  --slow: 900ms;
  --ease: cubic-bezier(.22, .61, .36, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--cream); }
body {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--apricot); outline-offset: 3px; border-radius: 10px; }
.noscript { padding: 4rem 2rem; text-align: center; font-family: var(--serif); font-size: 1.3rem; }

/* ------------------------------------------------------------ home */
.home { opacity: 1; transition: opacity var(--slow) var(--ease); animation: arrive 1.6s var(--ease) both; }
@keyframes arrive { from { opacity: 0; } to { opacity: 1; } }

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 6rem 1.5rem 4rem;
  overflow: hidden;
  isolation: isolate;
}
.hero-aura { position: absolute; inset: -20%; z-index: -1; filter: blur(60px); opacity: .9; }
.hero-aura i { position: absolute; border-radius: 50%; display: block; animation: drift 38s ease-in-out infinite alternate; }
.hero-aura i:nth-child(1) { width: 60vmax; height: 60vmax; left: 8%; top: 10%; background: radial-gradient(circle, rgba(124, 100, 186, .55), transparent 65%); }
.hero-aura i:nth-child(2) { width: 52vmax; height: 52vmax; right: 2%; top: 26%; background: radial-gradient(circle, rgba(242, 160, 130, .38), transparent 65%); animation-duration: 46s; animation-delay: -12s; }
.hero-aura i:nth-child(3) { width: 46vmax; height: 46vmax; left: 32%; bottom: -6%; background: radial-gradient(circle, rgba(90, 150, 170, .35), transparent 65%); animation-duration: 54s; animation-delay: -20s; }
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(4%, -3%, 0) scale(1.06); }
  100% { transform: translate3d(-3%, 4%, 0) scale(.97); }
}
.hero::after { /* soft grain so gradients never band */
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.home-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 1.2rem 1.4rem; }
.mark { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe2cf, var(--apricot) 40%, #8f78c8 100%); box-shadow: 0 0 28px rgba(242, 182, 154, .45); }
.home-actions { display: flex; gap: .4rem; }

.hero-inner { text-align: center; max-width: 46rem; }
.wordmark {
  font-family: var(--serif); font-weight: 400; letter-spacing: .14em; text-indent: .14em;
  font-size: clamp(2.6rem, 7vw, 4.8rem); margin: 0; line-height: 1.05;
  background: linear-gradient(180deg, #fff6ec, #e9d4c3); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { font-family: var(--serif); font-style: italic; font-size: clamp(1.15rem, 2.4vw, 1.5rem); margin: .8rem 0 0; color: var(--cream); opacity: .92; }
.lede { color: var(--cream-dim); margin: 1.4rem auto 0; max-width: 32rem; }

.begin { margin-top: 3rem; }
.begin-title { font-family: var(--serif); font-weight: 400; font-size: 1.1rem; letter-spacing: .04em; color: var(--cream-dim); margin: 0 0 1rem; }
.pills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; }
.pill {
  display: flex; flex-direction: column; gap: .15rem; text-decoration: none; text-align: left;
  padding: 1rem 1.1rem; border-radius: var(--radius);
  background: rgba(255, 255, 255, .045); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background .5s var(--ease), border-color .5s var(--ease), transform .5s var(--ease);
}
.pill:hover { background: rgba(255, 255, 255, .085); border-color: rgba(242, 182, 154, .35); transform: translateY(-2px); }
.pill.featured { background: linear-gradient(160deg, rgba(242, 182, 154, .16), rgba(169, 154, 214, .1)); border-color: rgba(242, 182, 154, .3); }
.pill-title { font-family: var(--serif); font-size: 1.08rem; }
.pill-sub { font-size: .82rem; color: var(--cream-faint); }
.wander { display: inline-block; margin-top: 2.6rem; color: var(--cream-faint); text-decoration: none; font-size: .9rem; letter-spacing: .06em; padding: .4rem .8rem; }
.wander::after { content: ""; display: block; width: 1px; height: 28px; margin: .6rem auto 0; background: linear-gradient(var(--cream-faint), transparent); }
.wander:hover { color: var(--cream); }

.shelf { max-width: 72rem; margin: 0 auto; padding: 3.5rem 1.5rem 1rem; }
.shelf-head { display: flex; align-items: baseline; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.shelf-head h2 { font-family: var(--serif); font-weight: 400; font-size: 1.7rem; margin: 0; }
.shelf-head p { margin: 0; color: var(--cream-faint); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1.2rem; }
.card {
  display: block; text-decoration: none; border-radius: calc(var(--radius) + 4px); overflow: hidden;
  background: var(--ink-2); border: 1px solid rgba(255, 255, 255, .06);
  transition: transform .7s var(--ease), border-color .7s var(--ease), box-shadow .7s var(--ease);
}
.card:hover, .card:focus-visible { transform: translateY(-3px); border-color: rgba(242, 182, 154, .25); box-shadow: 0 18px 50px rgba(0, 0, 0, .35); }
.card-art { aspect-ratio: 16 / 10; overflow: hidden; }
.card-art svg { width: 100%; height: 100%; display: block; transition: transform 1.6s var(--ease); }
.card:hover .card-art svg { transform: scale(1.035); }
.card-body { padding: 1rem 1.2rem 1.25rem; }
.card-body h3 { font-family: var(--serif); font-weight: 400; font-size: 1.25rem; margin: 0 0 .2rem; }
.card-body p { margin: 0; color: var(--cream-dim); font-size: .95rem; }

.home-foot { max-width: 72rem; margin: 4rem auto 0; padding: 2.5rem 1.5rem 3.5rem; border-top: 1px solid var(--glass-line); color: var(--cream-dim); font-size: .92rem; }
.home-foot p { margin: .3rem 0; }
.home-foot .fine { color: var(--cream-faint); font-size: .84rem; }
.link-btn { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; color: var(--cream-dim); }

/* ------------------------------------------------------------ buttons */
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--glass); border: 1px solid var(--glass-line); cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: background .4s var(--ease), border-color .4s var(--ease);
}
.icon-btn:hover { background: rgba(44, 38, 60, .8); border-color: rgba(239, 230, 218, .25); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.sound-btn.on { border-color: rgba(242, 182, 154, .4); }
.soft-btn {
  border-radius: 999px; padding: .7rem 1.3rem; cursor: pointer;
  background: rgba(255, 255, 255, .07); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: background .4s var(--ease);
}
.soft-btn:hover { background: rgba(255, 255, 255, .13); }
.soft-btn.primary { background: rgba(242, 182, 154, .22); border-color: rgba(242, 182, 154, .4); }

/* ------------------------------------------------------------ experience shell */
.xp { position: fixed; inset: 0; background: #000; overflow: hidden; user-select: none; -webkit-user-select: none; }
.xp-stage { position: absolute; inset: 0; }
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.xp-veil { position: absolute; inset: 0; background: var(--ink); pointer-events: none; opacity: 1; transition: opacity 1.8s var(--ease); z-index: 5; }
.xp.entered .xp-veil { opacity: 0; }
.xp.leaving .xp-veil { opacity: 1; transition-duration: 1s; }

.xp-title { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; z-index: 6; transition: opacity 2.2s var(--ease), transform 2.6s var(--ease); text-shadow: 0 2px 30px rgba(0, 0, 0, .45); }
.xp-title h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 5vw, 3.4rem); margin: .2rem 0 0; letter-spacing: .03em; }
.xp-title .kicker { font-size: .8rem; letter-spacing: .22em; text-transform: uppercase; color: var(--cream-dim); }
.xp-title { opacity: 0; transform: translateY(6px); }
.xp.entered .xp-title { opacity: 1; transform: none; }
.xp.entered .xp-title.gone { opacity: 0; transform: translateY(-6px); }

.xp-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) max(1.1rem, env(safe-area-inset-right)) 1rem max(1.1rem, env(safe-area-inset-left));
  transition: opacity 1.2s var(--ease); pointer-events: none;
}
.xp-bar > * { pointer-events: auto; }
.xp-actions, .xp-extra { display: flex; gap: .45rem; align-items: center; }
.xp-extra:empty { display: none; }
.xp-extra { margin-right: .4rem; }
.leave-btn {
  display: inline-flex; align-items: center; gap: .35rem; height: 42px; padding: 0 1rem 0 .7rem; border-radius: 999px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: .95rem;
}
.leave-btn .ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.leave-btn:hover { background: rgba(44, 38, 60, .8); }
.xp.ui-idle .xp-bar, .xp.ui-idle .xp-tools, .xp.ui-idle .g-bottom { opacity: 0; }
.xp.ui-idle .xp-bar > *, .xp.ui-idle .xp-tools, .xp.ui-idle .g-bottom { pointer-events: none; }
.xp.ui-idle { cursor: none; }
.xp.ambient .xp-hint { opacity: 0; }

.xp-hint {
  position: absolute; left: 50%; bottom: max(1.6rem, env(safe-area-inset-bottom)); transform: translate(-50%, 8px); z-index: 7;
  max-width: min(36rem, 88vw); text-align: center; padding: .6rem 1.1rem; border-radius: 999px;
  background: rgba(16, 14, 24, .5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--cream-dim); font-size: .92rem; opacity: 0; pointer-events: none;
  transition: opacity 1.4s var(--ease), transform 1.4s var(--ease);
}
.xp-hint.show { opacity: 1; transform: translate(-50%, 0); }

.xp-tools {
  position: absolute; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 7;
  display: flex; gap: .3rem; padding: .3rem; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: opacity 1.2s var(--ease);
}
.xp-tools button { border: 0; background: transparent; padding: .55rem 1.1rem; border-radius: 999px; cursor: pointer; color: var(--cream-dim); }
.xp-tools button.on { background: rgba(255, 255, 255, .12); color: var(--cream); }
.xp[data-xp="sand-garden"] .xp-hint { bottom: 5.2rem; }

/* ------------------------------------------------------------ panels */
.panel {
  position: fixed; top: 4.6rem; right: max(1rem, env(safe-area-inset-right)); z-index: 20;
  width: min(22rem, calc(100vw - 2rem)); max-height: calc(100vh - 6rem); overflow: auto;
  padding: 1.1rem 1.2rem 1.3rem; border-radius: var(--radius);
  background: rgba(22, 19, 32, .82); border: 1px solid var(--glass-line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
  opacity: 0; transform: translateY(-6px); transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.panel.open { opacity: 1; transform: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.panel-head h2 { font-family: var(--serif); font-weight: 400; font-size: 1.2rem; margin: 0; }
.panel-close { background: none; border: 0; color: var(--cream-dim); cursor: pointer; padding: .3rem .5rem; }
.panel-note { color: var(--cream-faint); font-size: .82rem; margin: 1rem 0 .4rem; }
.controls { display: flex; flex-direction: column; gap: 1rem; }
.ctl label, .ctl-label { display: flex; justify-content: space-between; font-size: .9rem; color: var(--cream-dim); margin-bottom: .4rem; }
.ctl-row { display: flex; justify-content: space-between; align-items: center; }
.ctl-row label { margin: 0; }
.ctl-value { color: var(--cream-faint); }
.ctl input[type=range] { width: 100%; accent-color: var(--apricot); height: 28px; }
.seg { display: flex; gap: .25rem; padding: .22rem; border-radius: 999px; background: rgba(255, 255, 255, .05); }
.seg button { flex: 1; border: 0; background: transparent; padding: .45rem .5rem; border-radius: 999px; cursor: pointer; font-size: .88rem; color: var(--cream-dim); }
.seg button.on { background: rgba(255, 255, 255, .13); color: var(--cream); }
.toggle { width: 46px; height: 26px; border-radius: 999px; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, .08); position: relative; cursor: pointer; transition: background .3s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--cream-dim); transition: transform .3s var(--ease), background .3s; }
.toggle.on { background: rgba(242, 182, 154, .4); }
.toggle.on::after { transform: translateX(20px); background: var(--cream); }
.ctl .soft-btn { width: 100%; }

/* ------------------------------------------------------------ guided journey */
.g-layer { position: absolute; inset: 0; opacity: 0; transition: opacity 4s var(--ease); }
.g-layer.in { opacity: 1; }
.g-layer.out { opacity: 0; }
.g-words { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 6; padding: 2rem; }
.g-words p {
  font-family: var(--serif); font-size: clamp(1.4rem, 3.4vw, 2.2rem); text-align: center; max-width: 30ch; margin: 0;
  text-shadow: 0 2px 24px rgba(0, 0, 0, .5); opacity: 0; transform: translateY(6px); transition: opacity 2.4s var(--ease), transform 2.8s var(--ease);
}
.g-words p.show { opacity: .95; transform: none; }
.g-bottom { position: absolute; left: 0; right: 0; bottom: max(1.4rem, env(safe-area-inset-bottom)); z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 1rem; transition: opacity 1.2s var(--ease); }
.g-dots { list-style: none; display: flex; gap: .3rem; margin: 0; padding: .3rem .5rem; border-radius: 999px; background: rgba(16, 14, 24, .42); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.g-dots button { display: flex; align-items: center; gap: .45rem; border: 0; background: none; cursor: pointer; padding: .4rem .55rem; border-radius: 999px; color: var(--cream-faint); font-size: .8rem; }
.g-dots button:hover { color: var(--cream); }
.g-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(239, 230, 218, .28); position: relative; overflow: hidden; flex: none; }
.g-dots li.done .g-dot { background: rgba(239, 230, 218, .6); }
.g-dots li.now .g-dot { background: rgba(239, 230, 218, .28); box-shadow: 0 0 0 2px rgba(242, 182, 154, .25); }
.g-dots li.now .g-dot::after { content: ""; position: absolute; inset: 0; background: var(--apricot); transform-origin: left; transform: scaleX(var(--p, 0)); }
.g-name { display: none; }
.g-dots li.now .g-name { display: inline; color: var(--cream-dim); }
.g-continue { opacity: 0; pointer-events: none; transition: opacity 2s var(--ease); }
.g-continue.show { opacity: 1; pointer-events: auto; }
.g-end { position: absolute; left: 50%; top: 64%; transform: translateX(-50%); z-index: 7; display: flex; gap: .7rem; flex-wrap: wrap; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 2.5s var(--ease); }
.g-end.show { opacity: 1; pointer-events: auto; }
.g-paused { position: absolute; left: 50%; top: 5.2rem; transform: translateX(-50%); z-index: 7; padding: .4rem 1rem; border-radius: 999px; background: rgba(16, 14, 24, .55); color: var(--cream-dim); font-size: .88rem; opacity: 0; transition: opacity .8s var(--ease); pointer-events: none; }
.g-paused.show { opacity: 1; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .pills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding-top: 5rem; }
  .xp-actions .icon-btn[title^="Full"] { display: none; }
  .panel { top: auto; bottom: 0; right: 0; left: 0; width: auto; border-radius: var(--radius) var(--radius) 0 0; max-height: 70vh; padding-bottom: max(1.3rem, env(safe-area-inset-bottom)); }
  .leave-btn span:last-child { display: none; }
  .leave-btn { width: 42px; padding: 0; justify-content: center; }
  .g-dots button { padding: .4rem .4rem; }
}

/* ------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hero-aura i { animation: none; }
  .card, .card-art svg, .pill { transition: none; }
}
.reduced-motion .hero-aura i { animation-duration: 160s; }
.reduced-motion .card:hover, .reduced-motion .pill:hover { transform: none; }
.reduced-motion .card:hover .card-art svg { transform: none; }
