/*
 * Comic panels: the frame, the aspect ratios, the placeholder for art that is
 * not there yet, and the lettering. Shared by comics.css and webtoon.css; the
 * markup comes from src/panels.ts and src/lettering.ts.
 *
 * Lettering is sized with container units so a balloon scales with its panel:
 * the same markup is legible at 358px on a phone and 1100px in a page grid.
 */

/* ── the frame ─────────────────────────────────────────────────────── */

.pn {
  --ar: 16 / 9;
  --arn: 1.7778; /* the same ratio as a plain number, for calc() */
  --ih: 56.25cqw; /* height of the art in container widths, for the sfx on a phone */
  position: relative;
  margin: 0;
  overflow: hidden;
  container-type: inline-size;
  aspect-ratio: var(--ar);
  background: var(--night-2);
  border: 3px solid var(--paper);
}
.pn-r169 {
  --ar: 16 / 9;
  --arn: 1.7778;
  --ih: 56.25cqw;
}
.pn-r43 {
  --ar: 4 / 3;
  --arn: 1.3333;
  --ih: 75cqw;
}
.pn-r34 {
  --ar: 3 / 4;
  --arn: 0.75;
  --ih: 133.333cqw;
}
.pn-r916 {
  --ar: 9 / 16;
  --arn: 0.5625;
  --ih: 177.778cqw;
}
.pn-r45 {
  --ar: 4 / 5;
  --arn: 0.8;
  --ih: 125cqw;
}
.pn > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── art not drawn yet ─────────────────────────────────────────────── */

/* A hatched frame with the scene's first sentence. Hard lines, no gradient. */
.pn-ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14cqw 9cqw;
  text-align: center;
  background:
    repeating-linear-gradient(135deg, rgba(217, 210, 189, 0.08) 0 2px, transparent 2px 12px), var(--night-2);
  outline: 2px dashed var(--line);
  outline-offset: -10px;
}
.pn-ph-tag {
  padding: 2px 10px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(14px, calc(1.2cqw + 6px), 18px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pn-ph-note {
  max-width: 34em;
  color: var(--text);
  font-size: clamp(15px, calc(2cqw + 7px), 24px);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  line-clamp: 6;
  overflow: hidden;
}

/* ── lettering ─────────────────────────────────────────────────────── */

.lt-let {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 1.2cqw;
  padding: 2.2cqw;
  pointer-events: none;
  font-size: clamp(13px, calc(2.2cqw + 4px), 21px);
}
.lt-let-top {
  top: 0;
  align-items: flex-start;
}
.lt-let-bot {
  bottom: 0;
  align-items: flex-start;
}

.lt-cap {
  margin: 0;
  max-width: 64%;
  padding: 0.35em 0.6em 0.4em;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 0.2em 0.2em 0 var(--ink);
  font-family: var(--body);
  font-weight: 600;
  font-size: 1em;
  line-height: 1.25;
}

.lt-bln {
  position: relative;
  margin: 0;
  max-width: 58%;
  font-family: var(--body);
  font-weight: 700;
  font-size: 1.05em;
  line-height: 1.2;
  text-align: center;
  /* a short line wraps evenly rather than leaving its last word alone */
  text-wrap: balance;
}
.lt-bln-l {
  align-self: flex-start;
}
.lt-bln-r {
  align-self: flex-end;
}
/* 4:3 portraits are close-ups: a narrower balloon stays off the face */
.pn-r43 .lt-bln {
  max-width: 40%;
}
/* a tall panel is narrow on screen, so its balloons and captions may take more of the width */
.pn-r34 .lt-bln,
.pn-r916 .lt-bln,
.pn-r45 .lt-bln {
  max-width: 68%;
}
.pn-r34 .lt-cap,
.pn-r916 .lt-cap,
.pn-r45 .lt-cap {
  max-width: 76%;
}
.lt-bln-speech {
  padding: 0.45em 0.8em 0.5em;
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 1.2em / 1em;
}
/* tail: ink triangle with a white one inset on top of it */
.lt-bln-speech::before,
.lt-bln-speech::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-color: transparent;
}
.lt-bln-speech::before {
  bottom: -0.95em;
  border-width: 0.95em 0.55em 0 0.55em;
  border-top-color: var(--ink);
}
.lt-bln-speech::after {
  bottom: -0.62em;
  border-width: 0.7em 0.38em 0 0.38em;
  border-top-color: #fff;
}
.lt-bln-speech.lt-bln-l::before {
  left: 18%;
}
.lt-bln-speech.lt-bln-l::after {
  left: calc(18% + 0.17em);
}
.lt-bln-speech.lt-bln-r::before {
  right: 18%;
}
.lt-bln-speech.lt-bln-r::after {
  right: calc(18% + 0.17em);
}

/* radio: Nyx's pirate signal. Jagged glitch-green outline, dark body. */
.lt-bln-radio {
  padding: 4px;
  background: #3bf08a;
  clip-path: polygon(0 10%, 3% 0, 8% 12%, 14% 0, 21% 10%, 29% 0, 37% 11%, 46% 0, 54% 10%, 63% 0, 71% 12%, 80% 0, 88% 10%, 95% 0, 100% 12%, 98% 34%, 100% 52%, 97% 74%, 100% 92%, 94% 100%, 86% 90%, 78% 100%, 69% 91%, 60% 100%, 51% 90%, 42% 100%, 33% 91%, 24% 100%, 15% 90%, 7% 100%, 0 90%, 2% 70%, 0 50%, 3% 30%);
}
.lt-bln-radio .lt-bln-t {
  display: block;
  padding: 0.5em 1em 0.55em;
  background: #06130c;
  color: #d9ffe9;
  font-style: italic;
}

.lt-sfx {
  position: absolute;
  right: 4cqw;
  bottom: 5cqw;
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(34px, 12cqw, 120px);
  line-height: 0.9;
  letter-spacing: 0.02em;
  color: var(--sodium);
  -webkit-text-stroke: 0.09em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0.05em 0.05em 0 var(--ink);
  transform: rotate(-9deg);
  pointer-events: none;
}
