*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --ink: rgba(248, 245, 240, 0.92);
  --ink-muted: rgba(248, 245, 240, 0.45);
  --panel: rgba(12, 12, 14, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);
  --accent: #c9a962;
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-ui: "Instrument Sans", system-ui, sans-serif;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  background: #0a0a0c;
  color: var(--ink);
  font-family: var(--font-ui);
  overflow: hidden;
}

/*
  All layers are position:absolute. A grid with only absolute children often
  computes to 0 height — use viewport units so the mirror always has area.
*/
#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

#feed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  z-index: 0;
  opacity: 1;
  transition: opacity 1.2s ease, width 0.4s ease, height 0.35s ease;
}

/* Video left; text lives only on the black right half (never overlaid on the feed). */
#app.layout-split #feed {
  left: 0;
  right: auto;
  width: 50%;
  height: 100%;
}

#app.video-hidden #feed {
  opacity: 0;
  pointer-events: none;
}

#app.video-hidden #text-stage {
  visibility: hidden;
}

#dark-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(ellipse 120% 80% at 50% 100%, rgba(8, 8, 12, 0.85), #050506);
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}

#app.video-hidden #dark-backdrop {
  opacity: 1;
}

#text-stage {
  position: absolute;
  inset: 0;
  z-index: 3;
  padding: clamp(1.5rem, 5vw, 4rem);
  padding-bottom: clamp(4rem, 12vh, 7rem);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  pointer-events: none;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent 0%, black 18%, black 85%, transparent 100%);
}

#app.layout-split #text-stage {
  left: 50%;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  height: 100%;
  margin: 0;
  padding: clamp(1.25rem, 3.5vw, 2.75rem);
  padding-top: clamp(2rem, 5vh, 3.5rem);
  justify-content: flex-start;
  align-items: flex-start;
  background: #050506;
  mask-image: none;
  overflow-x: hidden;
  overflow-y: auto;
  pointer-events: none;
}

@media (max-width: 640px) {
  #app.layout-split #feed {
    width: 100%;
    height: 44%;
    bottom: auto;
  }

  #app.layout-split #text-stage {
    left: 0;
    top: 44%;
    width: 100%;
    height: 56%;
  }
}

#scrims {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.scrim-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 45%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent);
}

/* Gradient only under the video strip, not on the text panel. */
#app.layout-split #scrims {
  left: 0;
  width: 50%;
  right: auto;
}

#app.layout-split .scrim-bottom {
  left: 0;
  right: 0;
  width: 100%;
}

@media (max-width: 640px) {
  #app.layout-split #scrims {
    width: 100%;
    height: 44%;
    bottom: auto;
    top: 0;
  }

  #app.layout-split .scrim-bottom {
    height: 40%;
  }
}

.fragment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 0.55em;
  margin-bottom: 0.9rem;
  align-items: baseline;
  max-width: 42ch;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: opacity 2.4s ease, filter 2.4s ease;
}

#app.layout-split .fragment-row {
  text-shadow: none;
}

.fragment-row.is-fading {
  opacity: 0.18;
  filter: blur(0.4px);
}

.word {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.7vw, 1.55rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.025em;
  color: var(--ink);
  opacity: 0;
  /* Longer ease so each word settles before the next stacks up */
  animation: word-in 2.35s cubic-bezier(0.25, 0.46, 0.35, 1) forwards;
}

@keyframes word-in {
  from {
    opacity: 0;
    transform: translateY(6px);
    filter: blur(2px);
  }
  55% {
    opacity: 0.88;
  }
  to {
    opacity: 0.92;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* —— Centred title card —— */
.title-card {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  pointer-events: none;
}

.title-card-inner {
  pointer-events: auto;
  width: min(440px, 100%);
  padding: 3rem 2.5rem 2.5rem;
  text-align: center;
  /* Solid base first — backdrop-filter alone can blank on some GPUs */
  background-color: rgb(14, 14, 18);
  border: 1px solid rgba(201, 169, 98, 0.22);
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 32px 64px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

@supports (backdrop-filter: blur(12px)) {
  .title-card-inner {
    background-color: rgba(14, 14, 18, 0.94);
    backdrop-filter: blur(18px);
  }
}

.title-card-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 400;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1.25;
}

.title-card-heading::before,
.title-card-heading::after {
  content: "";
  display: block;
  width: 3rem;
  height: 1px;
  margin: 0 auto;
  background: linear-gradient(90deg, transparent, rgba(201, 169, 98, 0.5), transparent);
}

.title-card-heading::before {
  margin-bottom: 1.5rem;
}

.title-card-heading::after {
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}

.title-card-actions {
  display: flex;
  justify-content: center;
}

.btn-start {
  flex: 0 1 auto;
  min-width: 200px;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.85rem 1.5rem;
  border-radius: 3px;
  border: 1px solid rgba(201, 169, 98, 0.55);
  background: linear-gradient(180deg, rgba(201, 169, 98, 0.18), rgba(201, 169, 98, 0.06));
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.btn-start:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(201, 169, 98, 0.28), rgba(201, 169, 98, 0.1));
  box-shadow: 0 0 24px rgba(201, 169, 98, 0.15);
  border-color: rgba(201, 169, 98, 0.75);
}

.btn-start:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.status {
  margin: 1.25rem 0 0;
  min-height: 2.5em;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  line-height: 1.45;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}

.status.is-error {
  color: #e8a598;
}

/* Title card leaves once the mirror runs (press Escape to stop and bring it back). */
.title-card {
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}

#app.running .title-card,
.title-card.is-dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
