:root {
  --navy: #080c18;
  --navy-deep: #04060d;
  --gold: #d4a94e;
  --gold-bright: #f0c96a;
  --gold-deep: #8a6a2f;
  --bronze-dark: #3c2a0c;
  --cream: #f3e9d2;
  --cream-dim: #cfc3a8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  /* a gallery wall at night: warm spotlight pooled around the painting,
     falling away to near-black at the edges */
  background:
    radial-gradient(ellipse 46% 58% at 26% 42%, rgba(212, 169, 78, 0.07), transparent 65%),
    radial-gradient(ellipse 60% 75% at 27% 45%, #121a2e 0%, transparent 62%),
    radial-gradient(ellipse at 50% 38%, #0b1120 0%, #060a13 55%, var(--navy-deep) 100%);
  color: var(--cream);
  font-family: "IM Fell English", Georgia, serif;
  cursor: default;
}

/* ---------- backdrop layers ---------- */

#motes {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 48%, rgba(2, 3, 7, 0.7) 100%);
}

/* ---------- layout ---------- */

#stage {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5vw;
  height: 100vh;
  padding: 3vh 4vw;
}

#head-zone {
  position: relative;
  flex: 0 0 auto;
}

/* overhead picture-light: a soft cone of warm light from above the frame */
#head-zone::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -18vh;
  transform: translateX(-50%);
  width: 160%;
  height: 70vh;
  pointer-events: none;
  background: radial-gradient(ellipse 42% 55% at 50% 0%, rgba(240, 201, 106, 0.13), transparent 72%);
}

#text-zone {
  /* claim all remaining wall space to the right of the painting */
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* fixed height + top anchor: the title never shifts while a
     pronouncement types and wraps below it */
  height: 82vh;
  padding-top: 6vh;
}

/* ---------- the painting ---------- */

#painting {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#frame {
  position: relative;
  padding: clamp(20px, 2vw, 34px);
  /* gilt molding lit by the picture light overhead: bright top face,
     falling into shadow at the bottom, with burnished-metal grain */
  border: 2px solid #171004;
  background:
    url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E"),
    linear-gradient(180deg,
      #e9cd82 0%,
      #cfa855 18%,
      #b18938 45%,
      #8f6c2a 72%,
      #6d5220 92%,
      #7d5f26 100%);
  background-blend-mode: soft-light, normal;
  box-shadow:
    /* carved bevel: catch-light on top lip, shade under the bottom lip */
    inset 0 3px 1px -1px rgba(255, 241, 200, 0.7),
    inset 0 -3px 2px -1px rgba(18, 11, 2, 0.75),
    inset 3px 0 2px -1px rgba(255, 241, 200, 0.25),
    inset -3px 0 2px -1px rgba(18, 11, 2, 0.45),
    /* concentric fillet rings within the gold band */
    inset 0 0 0 6px rgba(58, 41, 12, 0.45),
    inset 0 0 0 7px rgba(246, 220, 154, 0.45),
    /* the frame sitting off the wall */
    0 34px 80px -18px rgba(0, 0, 0, 0.95),
    0 4px 16px rgba(0, 0, 0, 0.6);
}

/* inner gilt fillets between frame and canvas */
#frame::after {
  content: "";
  position: absolute;
  inset: clamp(13px, 1.35vw, 23px);
  pointer-events: none;
  border: 3px solid rgba(38, 26, 8, 0.9);
  box-shadow:
    0 1px 0 rgba(246, 220, 154, 0.5),
    0 0 0 1px rgba(20, 13, 3, 0.6),
    inset 0 1px 0 rgba(246, 220, 154, 0.4),
    inset 0 0 0 1px rgba(246, 220, 154, 0.2);
}

#head {
  position: relative;
  height: min(72vh, 58vw);
  aspect-ratio: 1040 / 1513;
  overflow: hidden;
  animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1.0); }
  50%      { transform: scale(1.015); }
}

#head img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

#frame-base  { z-index: 1; }
#frame-speak { z-index: 2; opacity: 0; transition: opacity 60ms linear; }
#frame-blink { z-index: 3; opacity: 0; transition: opacity 150ms ease; }

#frame-speak.on { opacity: 1; }
#frame-blink.on { opacity: 1; }

/* canvas depth: soft shadow where canvas meets frame */
#head::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  box-shadow: inset 0 0 34px rgba(0, 0, 0, 0.55);
}

/* aged oil-on-canvas material: linen weave + varnish grain over the paint */
#head::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.55) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255, 245, 220, 0.5) 0 1px, transparent 1px 3px),
    url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='c'%3E%3CfeTurbulence type='turbulence' baseFrequency='0.055' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23c)' opacity='0.8'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: 0.14;
}

#glow {
  position: absolute;
  inset: -16%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 169, 78, 0.34) 0%, rgba(212, 169, 78, 0.1) 45%, transparent 70%);
  animation: glowpulse 5s ease-in-out infinite;
  filter: blur(12px);
}

@keyframes glowpulse {
  0%, 100% { opacity: 0.55; transform: scale(1.0); }
  50%      { opacity: 0.85; transform: scale(1.06); }
}

body.speaking #glow {
  animation-duration: 2.2s;
  background: radial-gradient(circle, rgba(240, 201, 106, 0.5) 0%, rgba(212, 169, 78, 0.18) 45%, transparent 70%);
}

/* ---------- the plaque ---------- */

#plaque {
  /* sized to the inscription, never wider than the frame */
  width: max-content;
  max-width: 94%;
  margin-top: clamp(0.9rem, 1.6vh, 1.5rem);
  padding: 0.7rem 1.6rem 0.85rem;
  text-align: center;
  background: linear-gradient(170deg, #34290f, #1e1608);
  border: 1px solid rgba(212, 169, 78, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(246, 220, 154, 0.25),
    0 8px 24px -10px rgba(0, 0, 0, 0.8);
}

.plaque-name {
  display: block;
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(1.25rem, 1.7vw, 1.6rem);
  font-weight: 600;
  letter-spacing: 0.24em;
  /* tracking adds a trailing space; offset it so the name centers optically */
  padding-left: 0.24em;
  color: var(--gold-bright);
}

.plaque-detail {
  display: block;
  margin-top: 0.15rem;
  font-style: italic;
  font-size: clamp(0.95rem, 1.25vw, 1.2rem);
  color: var(--cream-dim);
  line-height: 1.5;
}

/* ---------- the pronouncements ---------- */

.title {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 600;
  /* one full-width line; app.js fits the size to the column */
  font-size: clamp(2.8rem, 4.8vw, 5rem);
  white-space: nowrap;
  line-height: 1.12;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  text-shadow:
    0 2px 2px rgba(0, 0, 0, 0.7),
    0 0 50px rgba(212, 169, 78, 0.4);
}

.title-rule {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin: 2rem 0 3.2rem;
  color: var(--gold);
  font-size: 1.25rem;
}

.title-rule::before,
.title-rule::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, rgba(212, 169, 78, 0.7));
}

.title-rule::after {
  background: linear-gradient(90deg, rgba(212, 169, 78, 0.7), transparent);
}

.speech {
  font-style: italic;
  font-size: clamp(2.4rem, 3.9vw, 4.1rem);
  /* light type on a dark wall needs extra leading to breathe */
  line-height: 1.45;
  text-wrap: pretty;
  color: var(--cream);
}

.speech::before {
  content: "\201C";
  display: block;
  height: 0.32em;
  font-size: 2em;
  font-style: normal;
  line-height: 0.8;
  color: var(--gold);
}

.speech .cursor {
  display: inline-block;
  width: 0.55ch;
  color: var(--gold);
  animation: blinkcursor 900ms step-end infinite;
}

.speech .endquote {
  display: inline-block;
  font-size: 2em;
  line-height: 0;
  font-style: normal;
  color: var(--gold);
  margin-left: 0.12em;
  transform: translateY(0.17em);
}

@keyframes blinkcursor {
  50% { opacity: 0; }
}

/* screen-reader-only live region: hears the full line, sees nothing */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- narrow screens (portrait TV or dev window) ---------- */

@media (max-aspect-ratio: 5/4) {
  #stage { flex-direction: column; gap: 3vh; padding: 3vh 5vw; }
  #head { height: min(42vh, 74vw); }
  #text-zone { height: auto; padding-top: 0; flex: 0 1 auto; align-items: center; text-align: center; }
  .title-rule { justify-content: center; }
  .speech { max-width: 100%; min-height: 9rem; }
  .speech::before { display: inline; height: auto; margin-right: 0.1em; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  #head { animation: none; }
  #glow { animation: none; opacity: 0.7; }
  .speech .cursor { animation: none; }
}
