/* Trendline (public/trendline.js). A chart on graph paper: what happened up to the cutoff, a hatched
   stretch for what's to come, and your line drawn across it. Every screen fits the window
   (style.css caps the match area): the chart takes what's left. */
.tl { --tl-violet: #4f2c7f; --tl-mine: #ff7a59; display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; }
.tl > * { flex: none; }
.tl .gd-bar { flex-wrap: nowrap; margin-bottom: .85rem; }
.tl .gd-bar .gd-hint { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl .gd-bar .tl-bar-status { display: none; }

.tl-stage { display: flex; flex-direction: column; gap: .7rem; flex: 0 1 auto; height: clamp(17rem, 62vh, 32rem); min-height: 0; }
.tl-stage > * { flex: none; }
.tl-reveal .tl-stage { flex-direction: row; gap: 1.2rem; }

/* ---- The chart. ---- */
.tl .tl-card {
  display: flex; flex-direction: column; gap: .3rem; flex: 1 1 0; min-width: 0; min-height: 0; margin: 0; padding: .65rem .9rem .45rem;
  color: var(--gd-ink); background: var(--gd-paper); border: 3px solid var(--gd-ink); border-radius: 16px; box-shadow: 5px 5px 0 var(--gd-ink);
}
.tl-head { display: flex; align-items: baseline; justify-content: space-between; gap: .15rem 1rem; flex: none; flex-wrap: wrap; min-width: 0; }
.tl-title-row { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.tl-title { min-width: 0; font: 800 clamp(1.1rem, 2vw, 1.45rem)/1.15 var(--font); letter-spacing: -.01em; overflow-wrap: anywhere; }
.tl-place {
  flex: none; padding: .1rem .55rem .14rem; color: var(--gd-ink); background: #efe6ff; border: 2px solid var(--gd-ink); border-radius: 999px;
  font: 800 .78rem/1.15 var(--font); white-space: nowrap;
}
.tl-unit { color: var(--gd-muted); font: 750 .8rem/1.2 var(--font); }
.tl-plot { position: relative; flex: 1 1 0; min-height: 7rem; }
.tl-art { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; user-select: none; -webkit-user-select: none; }
.tl-plot.is-drawable .tl-art { cursor: crosshair; touch-action: none; }
.tl-credit { flex: none; margin: 0; overflow: hidden; color: var(--gd-muted); font-size: .68rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.tl-credit-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.tl-credit-link:hover, .tl-credit-link:focus-visible { color: var(--tl-violet); }

.tl-hatch-bg { fill: #f3edfb; }
.tl-hatch-line { stroke: #4f2c7f1c; stroke-width: 3.5px; }
.tl-question { fill: #4f2c7f2e; font: 800 64px/1 var(--font); pointer-events: none; }
.tl-gridline { stroke: #1b114018; stroke-width: 1px; stroke-dasharray: 3 4; }
.tl-axis { stroke: var(--gd-ink); stroke-width: 2px; }
.tl-cutoff { stroke: var(--gd-ink); stroke-width: 1.5px; stroke-dasharray: 5 4; opacity: .5; }
.tl-tick, .tl-year { fill: var(--gd-muted); font: 750 11.5px/1 var(--font); font-variant-numeric: tabular-nums; }
.tl-year-cutoff { fill: var(--gd-ink); font-weight: 800; }
.tl-area-fill { fill: #4f2c7f17; }
.tl-history-line { fill: none; stroke: var(--tl-violet); stroke-width: 4px; stroke-linejoin: round; stroke-linecap: round; }
.tl-anchor { fill: var(--tl-violet); stroke: #fffdf8; stroke-width: 2px; }
.tl-guide-ring { fill: none; stroke: var(--tl-mine); stroke-width: 3px; animation: tl-pulse 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.tl-guide-text { fill: #b8441f; font: 800 13px/1 var(--font); paint-order: stroke; stroke: #fffdf8; stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
@keyframes tl-pulse { 50% { transform: scale(1.35); opacity: .35; } }
.tl-mine-line { fill: none; stroke: var(--tl-mine); stroke-width: 4.2px; stroke-linejoin: round; stroke-linecap: round; }
.tl-mine-end { fill: var(--tl-mine); stroke: var(--gd-ink); stroke-width: 2px; }
.tl-mine-label, .tl-truth-label {
  fill: var(--gd-ink); font: 800 12.5px/1 var(--font); font-variant-numeric: tabular-nums;
  paint-order: stroke; stroke: #fffdf8; stroke-width: 4.5px; stroke-linejoin: round; pointer-events: none;
}
.is-locked .tl-mine-line { stroke-dasharray: none; }
.tl-guess { fill: none; stroke: var(--c); stroke-width: 3px; stroke-linejoin: round; stroke-linecap: round; opacity: .85; }
.tl-guess.is-fresh { animation: tl-fade .5s ease-out both; }
.tl-guess.is-mine { stroke-width: 4.2px; opacity: 1; }
.tl-guess.is-best { stroke-width: 5px; opacity: 1; filter: drop-shadow(0 0 3px var(--c)); }
.is-told .tl-guess:not(.is-best, .is-mine) { opacity: .4; }
@keyframes tl-fade { from { opacity: 0; } }
.tl-truth-halo { fill: none; stroke: #ffc845; stroke-width: 11px; stroke-linejoin: round; stroke-linecap: round; }
.tl-truth-line { fill: none; stroke: var(--gd-ink); stroke-width: 4.5px; stroke-linejoin: round; stroke-linecap: round; }
.tl-truth-head { fill: #ffc845; stroke: var(--gd-ink); stroke-width: 2.5px; }
.tl-truth-label { font-size: 13.5px; }
.tl-truth-label.is-final { font-size: 15px; }

/* ---- Drawing. ---- */
.tl-actions { display: flex; align-items: center; justify-content: flex-end; gap: .7rem; min-width: 0; }
.tl-note { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--muted); font-weight: 750; }
.tl .tl-clear {
  min-height: 2.6rem; padding: .2rem .95rem; color: var(--gd-ink); background: var(--gd-paper); border: 2.5px solid var(--gd-ink);
  border-radius: 999px; box-shadow: 2px 2px 0 var(--gd-ink); font: 800 .92rem/1 var(--font);
}
.tl .tl-clear:disabled { opacity: .45; box-shadow: none; }
.tl .tl-lock { min-height: 2.9rem; padding-inline: 1.6rem; font-size: 1.02rem; }
.tl :is(.tl-lock, .tl-clear)[hidden] { display: none; }

/* ---- The reveal. ---- */
.tl-side { display: flex; flex-direction: column; flex: 0 0 clamp(15rem, 30%, 21rem); min-width: 0; min-height: 0; }
.tl-rows { display: grid; align-content: start; gap: .38rem; flex: none; min-height: 0; margin: 0; padding: 0 4px 4px 0; overflow: hidden; list-style: none; }
.tl-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem; min-width: 0; padding: .24rem .6rem .24rem .3rem;
  color: var(--gd-ink); background: var(--gd-paper); border: 2.5px solid var(--gd-ink); border-left: 7px solid var(--c); border-radius: 12px;
  box-shadow: 3px 3px 0 var(--gd-ink); opacity: 0; translate: 14px 0; transition: opacity .3s, translate .4s cubic-bezier(.2, 1.4, .4, 1);
}
.tl-row.is-in { opacity: 1; translate: none; }
.tl-row.is-mine { background: #fff1c9; }
.tl-row .sb-face { width: 1.75rem; height: 1.75rem; border-width: 2px; font-size: .7rem; }
.tl-row-text { display: grid; min-width: 0; }
.tl-row-name, .tl-row-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-row-name { font: 800 .92rem/1.15 var(--font); }
.tl-row-sub { color: #b23a1c; font-size: .74rem; font-weight: 750; }
.tl-row-sub.is-right { color: #2c7a3a; }
.tl-row-points { font: 800 1rem/1 var(--font); font-variant-numeric: tabular-nums; }
.tl-row.is-called .tl-row-points::before { content: "★ "; color: #e3a400; }
.tl-row-mark { display: none; color: #b23a1c; font-weight: 800; }
.tl-row-mark.is-right { color: #2c7a3a; }
.tl-empty { color: var(--muted); font-weight: 700; }
.tl-many .tl-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .34rem .38rem; }
.tl-many .tl-row { gap: .32rem; padding-right: .4rem; }
.tl-many .tl-row .sb-face { width: 1.45rem; height: 1.45rem; }
.tl-many .tl-row-name { font-size: .82rem; }
.tl-many .tl-row-sub { font-size: .68rem; }
.tl-many .tl-row-points { font-size: .88rem; }
.tl-many .tl-side { flex-basis: clamp(17rem, 36%, 25rem); }

/* ---- Laptop heights. ---- */
@media (min-width: 46.01rem) and (max-height: 50rem) {
  .tl .gd-bar { margin-bottom: .6rem; }
  .tl-stage { height: clamp(15rem, 60vh, 28rem); gap: .55rem; }
  .tl .tl-lock { min-height: 2.6rem; }
  .tl .tl-clear { min-height: 2.4rem; }
}
@media (min-width: 46.01rem) and (max-height: 38rem) {
  .tl-stage { height: clamp(13rem, 58vh, 22rem); }
  .tl .tl-card { padding-block: .45rem .3rem; }
  .tl-row { padding-block: .14rem; }
  .tl-row-sub { display: none; }
}

/* ---- A phone (either way up): the round fills the screen. ---- */
@media (max-width: 46rem), (max-height: 30rem) {
  .tl { flex: 1 1 0; }
  .tl .gd-bar { margin-bottom: .5rem; }
  .tl .gd-bar .gd-hint { font-size: .84rem; }
  .tl-stage { flex: 1 1 0; height: auto; gap: .5rem; }
  .tl .tl-card { padding: .5rem .6rem .35rem; border-width: 2.5px; border-radius: 13px; box-shadow: 3px 3px 0 var(--gd-ink); }
  .tl-title { font-size: 1.02rem; }
  .tl-place { font-size: .7rem; border-width: 1.5px; }
  .tl-unit { font-size: .72rem; }
  .tl-credit { font-size: .6rem; }
  .tl .tl-lock { min-height: 2.6rem; padding-inline: 1.2rem; font-size: .95rem; }
  .tl .tl-clear { min-height: 2.4rem; padding-inline: .8rem; font-size: .86rem; }
  .tl-note { font-size: .84rem; line-height: 1.2; }
  .tl-guide-text { font-size: 12px; }
}
/* Upright: the chart above the players. */
@media (max-width: 46rem) and (min-height: 30.01rem) {
  .tl-draw .gd-bar .gd-hint { display: none; }
  .tl-draw .gd-bar .tl-bar-status { display: block; white-space: normal; line-height: 1.2; }
  .tl-draw .tl-note { display: none; }
  .tl-reveal .tl-stage { flex-direction: column; gap: .5rem; }
  .tl-reveal .tl-card { flex: 1 1 0; min-height: 11rem; }
  .tl-side, .tl-many .tl-side { flex: none; }
  .tl-reveal .tl-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem .35rem; }
  /* One line a player, so the chart keeps the room. */
  .tl-row { gap: .3rem; padding: .08rem .4rem .08rem .2rem; border-width: 2px; border-left-width: 5px; border-radius: 10px; box-shadow: 2px 2px 0 var(--gd-ink); }
  .tl-row .sb-face { width: 1.25rem; height: 1.25rem; border-width: 1.5px; }
  .tl-row-text { display: flex; align-items: baseline; gap: .28rem; }
  .tl-row-name { min-width: 0; font-size: .8rem; }
  .tl-row-sub { display: none; }
  .tl-row-mark { display: inline; flex: none; font-size: .78rem; }
  .tl-row-points { font-size: .84rem; }
}
/* Sideways: the players beside the chart. */
@media (max-height: 30rem) {
  .tl .gd-bar { margin-bottom: .35rem; }
  .tl-draw .tl-stage { flex-direction: row; gap: .6rem; }
  .tl-draw .tl-actions { flex: 0 0 8.2rem; flex-direction: column; align-items: stretch; justify-content: flex-end; gap: .45rem; }
  .tl-draw .tl-note { flex: 0 1 auto; font-size: .76rem; }
  .tl .tl-card { padding: .4rem .55rem .3rem; }
  .tl-title { font-size: .92rem; }
  .tl-row-text { display: flex; align-items: baseline; gap: .28rem; }
  .tl-row-mark { display: inline; flex: none; font-size: .74rem; }
  .tl-head { flex-wrap: nowrap; }
  .tl-unit { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tl-side, .tl-many .tl-side { flex: 0 0 40%; }
  .tl-reveal .tl-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .26rem .3rem; }
  .tl-row { gap: .3rem; padding: .1rem .35rem .1rem .22rem; border-width: 2px; border-left-width: 5px; box-shadow: 2px 2px 0 var(--gd-ink); }
  .tl-row .sb-face { width: 1.3rem; height: 1.3rem; }
  .tl-row-name { font-size: .76rem; }
  .tl-row-sub { display: none; }
  .tl-row-points { font-size: .82rem; }
}
