:root {
  /* Compliance typography tokens from DESIGN.md: Space Mono** `lovable.dev` wordmark Space Mono**. IBM Plex Mono** */
  --velvet: #4A0F1F;
  --ox: #7B1E32;
  --rose: #B84A62;
  --cream: #F7E8C8;
  --gold: #C79A45;
  --violet: #24112E;
  --aurora: #86F0C1;
  --space: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --plex: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --dm: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background:
    radial-gradient(circle at 18% 6%, rgba(134, 240, 193, 0.18), transparent 28rem),
    radial-gradient(circle at 82% 18%, rgba(184, 74, 98, 0.24), transparent 26rem),
    linear-gradient(140deg, var(--violet), var(--velvet) 45%, #2b0d20 100%);
  font-family: var(--plex);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(90deg, rgba(247, 232, 200, 0.025) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(0deg, rgba(36, 17, 46, 0.09) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
  opacity: 0.65;
  z-index: 30;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.38;
  z-index: 25;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(247,232,200,0.11) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,0.17) 0 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px;
  animation: grainShift 1.6s steps(3) infinite;
}

.aurora {
  position: fixed;
  width: 70vw;
  height: 70vh;
  border-radius: 50%;
  filter: blur(58px) url(#velvet-waver);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}

.aurora-one {
  top: -22vh;
  left: -16vw;
  background: conic-gradient(from 30deg, transparent, rgba(134,240,193,0.48), rgba(184,74,98,0.28), transparent, rgba(199,154,69,0.22));
  animation: auroraDrift 23s ease-in-out infinite alternate;
}

.aurora-two {
  right: -24vw;
  top: 25vh;
  background: conic-gradient(from 190deg, transparent, rgba(123,30,50,0.52), rgba(134,240,193,0.31), rgba(247,232,200,0.14), transparent);
  animation: auroraDriftTwo 29s ease-in-out infinite alternate;
}

.filter-bank { position: fixed; width: 0; height: 0; }
.filter-bank::before { content: "Mono** Mono**."; }
.salon { position: relative; z-index: 1; }
.chamber { min-height: 100vh; position: relative; padding: clamp(28px, 5vw, 76px); }

.threshold {
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
}

.curtain {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background: repeating-linear-gradient(90deg, rgba(36,17,46,0.35) 0 20px, rgba(74,15,31,0.85) 20px 44px, rgba(123,30,50,0.35) 44px 58px);
  opacity: 0.45;
  filter: drop-shadow(0 0 32px rgba(0,0,0,0.4));
  animation: curtainLift 2.2s cubic-bezier(.2,.8,.2,1) forwards;
}
.left-curtain { left: 0; transform-origin: left; }
.right-curtain { right: 0; transform-origin: right; }

.threshold-arch {
  position: relative;
  width: min(920px, 92vw);
  min-height: 72vh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: clamp(36px, 7vw, 92px) clamp(22px, 5vw, 72px);
  text-align: center;
  border: 1px solid rgba(199,154,69,0.72);
  border-top-left-radius: 46% 18%;
  border-top-right-radius: 46% 18%;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  background:
    radial-gradient(circle at 50% 16%, rgba(134,240,193,0.24), transparent 32%),
    linear-gradient(180deg, rgba(247,232,200,0.11), rgba(74,15,31,0.58));
  box-shadow: inset 0 0 0 10px rgba(247,232,200,0.035), inset 0 0 0 13px rgba(199,154,69,0.28), 0 42px 120px rgba(0,0,0,0.45);
}

.threshold-arch::before,
.threshold-arch::after,
.tile::before,
.mirror-frame::before {
  content: "";
  position: absolute;
  pointer-events: none;
}

.threshold-arch::before {
  inset: 20px;
  border: 1px dashed rgba(199,154,69,0.48);
  border-top-left-radius: 46% 18%;
  border-top-right-radius: 46% 18%;
}

.arch-ornament, .filigree { color: var(--gold); font-family: var(--space); }
.arch-ornament { font-size: clamp(18px, 3vw, 34px); letter-spacing: .5em; margin-bottom: 34px; }
.filigree { position: absolute; top: 45%; font-size: clamp(70px, 13vw, 170px); opacity: .42; animation: morphCurl 7s ease-in-out infinite alternate; }
.filigree-left { left: 5%; }
.filigree-right { right: 5%; }
.eyebrow, .drawer-number, .section-kicker, .threshold-footer, .receipt-caption { font-family: var(--dm); text-transform: uppercase; letter-spacing: .18em; }
.eyebrow { color: var(--aurora); font-size: 12px; }

h1, h2, h3 { font-family: var(--space); margin: 0; font-weight: 700; }
h1 {
  font-size: clamp(54px, 12vw, 156px);
  line-height: .9;
  letter-spacing: .08em;
  background: linear-gradient(110deg, var(--cream), var(--gold) 34%, var(--rose) 70%, var(--cream));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 32px rgba(184,74,98,0.18);
}

.threshold-copy { max-width: 690px; font-size: clamp(15px, 2vw, 20px); line-height: 1.8; color: rgba(247,232,200,.82); }
.inspect-button, .drawer-toggle, .charm {
  border: 1px solid var(--gold);
  color: var(--cream);
  background: linear-gradient(135deg, rgba(123,30,50,.84), rgba(36,17,46,.86));
  font-family: var(--dm);
  letter-spacing: .08em;
  cursor: pointer;
  box-shadow: inset 0 0 18px rgba(199,154,69,.12), 0 10px 30px rgba(0,0,0,.25);
}
.inspect-button { margin-top: 18px; padding: 16px 22px; border-radius: 999px; text-transform: lowercase; }
.inspect-button:hover, .drawer-toggle:hover, .charm:hover, .charm.active { color: var(--aurora); border-color: var(--aurora); transform: translateY(-2px); }
.threshold-footer { position: absolute; bottom: 26px; display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; color: rgba(247,232,200,.55); font-size: 10px; }

.cabinet { padding-top: 90px; }
.section-ribbon { max-width: 760px; margin: 0 auto 36px; text-align: center; }
.section-ribbon span { color: var(--gold); font-family: var(--dm); letter-spacing: .26em; text-transform: uppercase; }
h2 { font-size: clamp(34px, 6vw, 76px); letter-spacing: .05em; color: var(--cream); }
.section-ribbon p, .mirror-frame > p { line-height: 1.8; color: rgba(247,232,200,.72); }

.masonry {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 72px;
  gap: 18px;
  max-width: 1220px;
  margin: 0 auto;
  align-items: stretch;
}

.tile {
  position: relative;
  overflow: hidden;
  grid-column: span 3;
  grid-row: span 4;
  padding: 24px;
  color: var(--violet);
  background:
    radial-gradient(circle at var(--glow-x, 50%) var(--glow-y, 20%), rgba(134,240,193,.28), transparent 38%),
    linear-gradient(145deg, rgba(247,232,200,.96), rgba(247,232,200,.76));
  border: 1px solid rgba(199,154,69,.78);
  box-shadow: inset 0 0 0 5px rgba(74,15,31,.04), 0 22px 44px rgba(0,0,0,.26);
  transition: transform .45s ease, box-shadow .45s ease, border-radius .45s ease;
  opacity: 0;
  translate: 0 18px;
}
.tile.in-view { opacity: 1; translate: 0 0; transition: transform .45s ease, box-shadow .45s ease, border-radius .45s ease, opacity .7s ease, translate .7s ease; }
.tile::before { inset: 10px; border: 1px solid rgba(123,30,50,.24); border-radius: inherit; }
.tile:hover { transform: translateY(-8px) rotate(var(--tilt, 0deg)); box-shadow: 0 34px 70px rgba(0,0,0,.38), 0 0 30px rgba(134,240,193,.12); }
.tile h3 { color: var(--ox); font-size: clamp(21px, 2vw, 34px); line-height: 1.05; margin: 12px 0; }
.tile p { line-height: 1.6; }
.drawer-number { font-size: 10px; color: var(--rose); }
.span-2 { grid-column: span 4; }
.wide { grid-column: span 6; }
.narrow { grid-column: span 2; }
.tall { grid-row: span 6; }
.round { border-radius: 50%; display: grid; place-items: center; text-align: center; aspect-ratio: 1; grid-row: span 4; }
.tile-arch { border-top-left-radius: 48% 18%; border-top-right-radius: 48% 18%; }
.tile-receipt { background: linear-gradient(180deg, #F7E8C8, #ead3a3); }
.tile-ribbon { background: linear-gradient(180deg, var(--ox), var(--velvet)); color: var(--cream); border-radius: 100px; text-align: center; }
.tile-ribbon p { color: rgba(247,232,200,.82); font-size: 12px; }
.tile-ribbon strong { color: var(--aurora); }
.vertical-label { writing-mode: vertical-rl; margin: auto; color: var(--gold); font-family: var(--dm); letter-spacing: .16em; text-transform: uppercase; }
.tile-manuscript { display: flex; gap: 20px; align-items: center; border-radius: 18px 60px 18px 60px; }
.illuminated { font-family: var(--space); font-size: 120px; color: var(--gold); line-height: .8; text-shadow: 3px 3px 0 var(--ox); }
.tile-seal { background: linear-gradient(160deg, var(--cream), #dcbf83); border-radius: 32px; }
.tile-code { background: linear-gradient(180deg, rgba(36,17,46,.96), rgba(74,15,31,.94)); color: var(--cream); border-radius: 20px; }
.tile-code p { font-size: 12px; }
.glyph-line { color: var(--aurora); font-size: 22px !important; }
.tile-moth { border-top-left-radius: 140px; border-top-right-radius: 140px; background: linear-gradient(180deg, rgba(247,232,200,.9), rgba(184,74,98,.28)); }

pre { margin: 18px 0; padding: 14px; color: var(--cream); background: var(--violet); border-left: 2px solid var(--gold); overflow: hidden; font: 13px/1.8 var(--plex); }
.gold-rule { height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); transform-origin: left; animation: drawRule 5s ease-in-out infinite; }
.hidden-note { display: block; margin-top: 16px; max-height: 0; opacity: 0; color: var(--rose); font-family: var(--dm); transition: max-height .4s ease, opacity .4s ease; }
.tile:hover .hidden-note, .tile.revealed .hidden-note { max-height: 70px; opacity: 1; }
.drawer-toggle { padding: 10px 14px; border-radius: 999px; color: var(--cream); }
.drawer-story { margin-top: 12px; padding: 0 14px; max-height: 0; opacity: 0; overflow: hidden; border-left: 1px solid var(--gold); line-height: 1.6; transition: all .48s ease; }
.tile-drawer.open .drawer-story { max-height: 180px; opacity: 1; padding-top: 12px; padding-bottom: 12px; }
.cameo-face, .wax-seal { display: grid; place-items: center; margin: 0 auto 12px; font-family: var(--space); }
.cameo-face { width: 82px; height: 82px; border: 3px double var(--gold); border-radius: 50%; color: var(--rose); font-size: 38px; }
.wax-seal { width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle, var(--rose), var(--ox)); color: var(--cream); box-shadow: inset 0 0 0 7px rgba(74,15,31,.24); }
.moth { position: relative; width: 148px; height: 108px; margin: 12px auto 30px; }
.moth::before, .moth::after { content: ""; position: absolute; top: 12px; width: 72px; height: 86px; border: 1px solid var(--gold); background: radial-gradient(circle at 50% 40%, rgba(134,240,193,.5), rgba(184,74,98,.18) 55%, rgba(247,232,200,.36)); animation: wing 3.8s ease-in-out infinite; }
.moth::before { left: 5px; border-radius: 80% 18% 65% 30%; transform-origin: right center; }
.moth::after { right: 5px; border-radius: 18% 80% 30% 65%; transform-origin: left center; }
.moth span { position: absolute; left: 70px; top: 16px; width: 8px; height: 88px; border-radius: 8px; background: var(--ox); z-index: 2; }

.mirror { display: grid; place-items: center; }
.mirror-frame {
  position: relative;
  width: min(1040px, 92vw);
  min-height: 72vh;
  padding: clamp(32px, 6vw, 76px);
  border: 1px solid var(--gold);
  border-radius: 46px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(134,240,193,.18), transparent 34%),
    linear-gradient(145deg, rgba(36,17,46,.88), rgba(10,4,13,.92));
  box-shadow: inset 0 0 80px rgba(123,30,50,.28), 0 40px 120px rgba(0,0,0,.48);
}
.mirror-frame::before { inset: 18px; border: 1px dashed rgba(199,154,69,.36); border-radius: 34px; }
.section-kicker { color: var(--aurora); letter-spacing: .24em; }
.charms { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin: 38px 0; }
.charm { padding: 13px 17px; border-radius: 999px; transition: all .25s ease; }
.reflection { max-width: 720px; min-height: 68px; margin: 0 auto; color: var(--cream) !important; font-size: clamp(17px, 2vw, 24px); }
.reflection.rewriting { color: var(--aurora) !important; text-shadow: 0 0 16px rgba(134,240,193,.36); }
.cursor-brooch { position: fixed; left: 0; top: 0; width: 18px; height: 18px; border: 1px solid var(--gold); border-radius: 50% 50% 50% 0; transform: translate(-80px,-80px) rotate(-45deg); pointer-events: none; z-index: 40; box-shadow: 0 0 18px rgba(134,240,193,.5); }

@keyframes grainShift { 0% { transform: translate(0,0); } 50% { transform: translate(1px,-1px); } 100% { transform: translate(-1px,1px); } }
@keyframes auroraDrift { from { transform: translate(0,0) rotate(0deg) scale(1); } to { transform: translate(16vw,18vh) rotate(34deg) scale(1.18); } }
@keyframes auroraDriftTwo { from { transform: translate(0,0) rotate(0deg) scale(1); } to { transform: translate(-20vw,-8vh) rotate(-28deg) scale(1.08); } }
@keyframes curtainLift { to { transform: scaleX(.18); opacity: .12; } }
@keyframes morphCurl { from { transform: translateY(-50%) scaleX(.72); } to { transform: translateY(-50%) scaleX(1.08) rotate(4deg); } }
@keyframes drawRule { 0%, 100% { transform: scaleX(.05); opacity: .3; } 50% { transform: scaleX(1); opacity: 1; } }
@keyframes wing { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(7deg); } }

@media (max-width: 920px) {
  .masonry { grid-template-columns: repeat(6, 1fr); grid-auto-rows: 78px; }
  .tile, .span-2, .wide { grid-column: span 3; }
  .narrow { grid-column: span 2; }
}

@media (max-width: 640px) {
  .chamber { padding: 24px 16px; }
  .threshold-arch { min-height: 76vh; }
  .masonry { display: block; }
  .tile { margin: 16px 0; min-height: 260px; }
  .round { aspect-ratio: auto; border-radius: 42px; }
  .tile-manuscript { flex-direction: column; text-align: center; }
  .cursor-brooch { display: none; }
}
