/* ------------------------------------------------------------------
   main.css: component styles for the dialogue prototype.
   All values come from tokens.css (generated from tokens/tokens.json).
   Load tokens.css before this file.
   ------------------------------------------------------------------ */

*{ box-sizing:border-box; }

html,body{ height:100%; margin:0; }

body{
  font-family: var(--font-body);
  color: var(--color-ink);
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(255,255,255,0.35), transparent 60%),
    repeating-linear-gradient(135deg, var(--color-bg) 0px, var(--color-bg) 2px, var(--color-bg-grain) 2px, var(--color-bg-grain) 4px);
  background-color: var(--color-bg);
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:100vh;
  padding: 32px 24px;
  /* keep the centred content clear of the pinned promo card */
  padding-top: calc(var(--layout-promo-thumb) + var(--layout-promo-offset) * 2 + 24px);
}

.screen{ display:none; width:100%; }
.screen.active{ display:flex; flex-direction:column; align-items:center; }

/* ================= TITLE + END SCREENS ================= */
.cover{
  width:100%;
  max-width: 500px;
  background: var(--color-panel);
  border: 1.5px solid var(--color-panel-edge);
  border-radius: var(--radius-cover);
  padding: 48px 36px 40px;
  text-align:center;
}

.cover .eyebrow{
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-ink-soft);
  margin: 0 0 10px;
}

.cover h1{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.6rem;
  color: var(--color-ink);
  margin: 0 0 14px;
  position:relative;
  display:inline-block;
}

.cover h1 svg{
  position:absolute; left:0; bottom:-10px; width:100%; height:10px; overflow:visible;
}
.cover h1 svg path{ stroke: var(--color-accent); }

.cover p.sub{
  font-size: 1rem;
  line-height:1.6;
  color: var(--color-ink-soft);
  margin: 0 auto 30px;
  max-width: 34ch;
}

.cover-cast{
  display:flex;
  justify-content:center;
  align-items:flex-end;
  gap: 8px;
  margin: 0 auto 22px;
}

.cover-portrait{
  width: 130px;
  height: calc(130px * 682 / 436);
  background-repeat:no-repeat;
}

.primary-btn{
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--color-on-accent);
  background: var(--color-accent);
  border: none;
  padding: 13px 30px;
  border-radius: var(--radius-control);
  cursor: pointer;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 0 var(--color-accent-dark);
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
}
.primary-btn:hover{ background: var(--color-accent-dark); }
.primary-btn:active{ transform: translateY(3px); box-shadow: 0 1px 0 var(--color-accent-dark); }
.primary-btn:focus-visible{ outline: 2px solid var(--color-ink); outline-offset: 2px; }

/* ================= PROMO CARD (pinned top right) ================= */
.promo-card{
  position: fixed;
  top: var(--layout-promo-offset);
  right: var(--layout-promo-offset);
  z-index: 10;
  display:flex;
  align-items:center;
  gap: 14px;
  max-width: calc(100vw - var(--layout-promo-offset) * 2);
  padding: 10px 16px 10px 10px;
  background: var(--color-panel);
  border: 1.5px solid var(--color-panel-edge);
  border-radius: var(--radius-panel);
  box-shadow: 0 4px 0 rgba(46,38,32,0.12);
  color: var(--color-ink);
  text-decoration: none;
}

.promo-thumb{
  flex: none;
  width: var(--layout-promo-thumb);
  height: var(--layout-promo-thumb);
  border-radius: var(--radius-control);
  border: 1.5px solid var(--color-panel-edge);
  object-fit: cover;
  display:block;
}

.promo-info{
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap: 6px;
  min-width: 0;
}

.promo-title{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.2;
}

.promo-price{
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.promo-btn{
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align:center;
  color: var(--color-accent-dark);
  border: 1.5px solid var(--color-panel-edge);
  border-radius: var(--radius-control);
  padding: 8px 16px;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}

.promo-card:hover .promo-btn{
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}
.promo-card:focus-visible{ outline: 2px solid var(--color-ink); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce){
  .promo-btn{ transition: none; }
}

/* ================= DIALOGUE SCREEN ================= */
.stage{
  position:relative;
  width:100%;
  max-width: 880px;
  margin-top: calc(var(--layout-char-h) - var(--layout-overlap));
}

.character{
  position:absolute;
  top: calc(-1 * (var(--layout-char-h) - var(--layout-overlap)));
  width: var(--layout-char-w);
  height: var(--layout-char-h);
  z-index: 2;
  /* fading out is quick; fading in comes from .reveal below */
  transition: opacity 180ms ease-out;
}
.character.left { left:  var(--layout-char-inset); }
.character.right{ right: var(--layout-char-inset); }

.character .sprite{
  width:100%;
  height:100%;
  background-repeat:no-repeat;
}
.character .sprite.flip{ transform: scaleX(-1); }

/* only the speaker is visible */
.character.is-speaking{ opacity: 1; }
.character.is-listening{ opacity: 0; }

/* one shared reveal: the new speaker, their name tag and their line
   all run this same animation together, so they appear in sync */
@keyframes reveal{
  from{ opacity: 0; }
  to  { opacity: 1; }
}
.reveal{
  animation: reveal var(--motion-reveal-duration) var(--motion-reveal-ease) var(--motion-reveal-delay) both;
}

.dialogue-box{
  position:relative;
  z-index:1;
  background: var(--color-panel);
  border: 1.5px solid var(--color-panel-edge);
  border-radius: var(--radius-panel);
}

.box-header{
  min-height: var(--layout-overlap);
  display:flex;
  align-items:center;
  padding: 14px var(--layout-name-inset) 4px;
}
.box-header.from-left { justify-content:flex-start; }
.box-header.from-right{ justify-content:flex-end; }

/* name tag: its own container, bottom-centre of each portrait */
.name-tag{
  position:absolute;
  left:50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 1;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--color-tag-ink);
  background: var(--tag-color);
  border: 1.5px solid var(--color-tag-ink);
  padding: 7px 17px 8px;
  border-radius: var(--radius-control);
  box-shadow: 0 3px 0 rgba(46,38,32,0.2);
}
#charMatty .name-tag{ --tag-color: var(--color-character-matty); }
#charJules .name-tag{ --tag-color: var(--color-character-jules); }

.visually-hidden{
  position:absolute; width:1px; height:1px; margin:-1px; padding:0;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

.box-body{
  padding: 4px 24px 22px;
  margin: 0 24px;
}

.dialogue-text{
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--color-ink);
  margin: 18px auto 24px;
  min-height: 3.6em;
  max-width: 62ch;
}

.box-footer{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 12px;
}

.nav-buttons{ display:flex; gap:10px; }

.nav-btn{
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  border: none;
  padding: 11px 22px;
  border-radius: var(--radius-control);
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease, opacity 80ms ease;
}

.nav-btn.next{
  color: var(--color-on-accent);
  background: var(--color-accent);
  box-shadow: 0 4px 0 var(--color-accent-dark);
}
.nav-btn.next:hover{ background: var(--color-accent-dark); }
.nav-btn.next:active{ transform: translateY(3px); box-shadow: 0 1px 0 var(--color-accent-dark); }

.nav-btn.back{
  color: var(--color-accent-dark);
  background: transparent;
  border: 1.5px solid var(--color-panel-edge);
}
.nav-btn.back:hover{ background: var(--color-accent-tint); }
.nav-btn.back:disabled{
  opacity: 0.35;
  cursor: not-allowed;
  background: transparent;
}

.nav-btn:focus-visible{ outline: 2px solid var(--color-ink); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce){
  .character{ transition: none; }
  .reveal{ animation: none; }
}

/* mobile: both portraits sit side by side above the box, no overlap.
   (the token values for this breakpoint live in tokens.json) */
@media (max-width: 640px){
  .stage{
    margin-top: 0;
    display:grid;
    grid-template-columns: 1fr 1fr;
    row-gap: 14px;
  }

  .character{
    /* relative (not static) so the name tag stays anchored to its portrait */
    position: relative;
    top: auto; left: auto; right: auto;
    justify-self:center;
    grid-row: 1;
  }
  .character.left { grid-column: 1; left: auto; }
  .character.right{ grid-column: 2; right: auto; }

  .dialogue-box{ grid-column: 1 / -1; grid-row: 2; }

  .box-header{ min-height: 0; }
  .box-body{ margin: 0 16px; padding: 4px 0 20px; }
  .dialogue-text{ font-size: 0.98rem; }
  .name-tag{ font-size: 1rem; padding: 7px 14px 8px; bottom: 8px; }
  .cover{ padding: 36px 24px 32px; }
  .cover h1{ font-size: 2.1rem; }
  .cover-portrait{ width: 110px; height: calc(110px * 682 / 436); }

  .promo-card{ position: absolute; gap: 10px; padding: 8px 12px 8px 8px; }
  .promo-title{ font-size: 0.95rem; }
  .promo-price{ font-size: 0.85rem; }
  .promo-btn{ margin-top: 0; padding: 6px 12px; }
}
