/*
 * Clef head to head (css/duel.css): /duel only, after css/clef.css and css/app.css (the stat, the yours-head and the
 * chip come from /app). The two sides, the big record, the hour strip, the means, both sides' calibration and the
 * picker. Checked from 320 px: names and labels wrap anywhere, the strip's cells shrink to fit 24 in a row.
 * CSP: no inline styles.
 */

main[data-duel-root] { min-height: calc(100svh - var(--hdr-h, 64px)); }

/* ------------------------------------------------------------------ head */

.dl-head { display: grid; gap: 14px; padding-top: clamp(28px, 5vw, 56px); }
.dl-title { min-width: 0; font: 600 clamp(28px, 4.6vw, 48px)/1.1 var(--display); letter-spacing: -.025em; color: var(--ink); overflow-wrap: anywhere; text-wrap: balance; }
.dl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dl-bar .btn { display: inline-flex; gap: 6px; }
.dl-bar .btn[hidden] { display: none; }
@media (max-width: 380px) { .dl-seg { flex: 1 1 100%; } .dl-seg button { flex: 1 1 0; padding: 0 8px; } }

/* ------------------------------------------------------------------ the two sides and the record */

/* one column that never grows past the page: a long unbreakable record would otherwise widen every row in it */
.dl-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; margin-top: clamp(22px, 3vw, 32px); }
.dl-main[hidden] { display: none; }
.dl-sides { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: 12px; }
.dl-vs { align-self: center; font: 600 13px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dl-side { display: flex; flex-wrap: wrap; align-items: center; align-content: start; gap: 6px 10px; min-width: 0; padding: 16px 18px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--paper); }
.dl-side.is-a { border-color: var(--amber-soft); background: var(--cream); }
.dl-key { flex: none; width: 12px; height: 12px; border-radius: 3px; }
.is-a .dl-key { background: var(--orange); }
.is-b .dl-key { background: var(--ink); }
.dl-name { min-width: 0; font: 600 clamp(16px, 2vw, 19px)/1.25 var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.dl-tag { flex: none; padding: 3px 7px; border-radius: 999px; background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); font: 600 10.5px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; }
.dl-agent { flex: 1 1 100%; min-width: 0; font: 500 12.5px/1.45 var(--sans); color: var(--muted); overflow-wrap: anywhere; }
.dl-meta { flex: 1 1 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; min-width: 0; font-size: 12.5px; line-height: 1.45; }
.dl-hours { min-width: 0; color: var(--body); }
@media (max-width: 640px) {
  .dl-sides { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .dl-vs { justify-self: center; }
  .dl-side { padding: 12px 14px; }
}

.dl-msg { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border: 1px dashed var(--line-2); border-radius: var(--r-md); background: var(--alabaster); font-size: 14.5px; line-height: 1.55; color: var(--body); }
.dl-msg[hidden] { display: none; }
.dl-msg-ico { flex: none; display: inline-flex; color: var(--faint); margin-top: 1px; }
.dl-msg p { min-width: 0; overflow-wrap: anywhere; text-wrap: pretty; }

.dl-rec { display: grid; gap: 6px; }
.dl-rec-v { font: 700 clamp(64px, 15vw, 132px)/.95 var(--display); letter-spacing: -.04em; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/*
 * js/duel.js sets --rec-len (the record's characters). A tabular digit of Inter Tight 700 is .648em, less .04em of
 * letter spacing: .62em a character keeps "100-20-48" (9) and longer all time records inside the column on a 320 px
 * phone instead of clipped at its edge; short records keep the big size.
 */
.dl-rec-v { font-size: min(clamp(64px, 15vw, 132px), calc(min(100vw - 2 * var(--gutter), var(--wrap)) / (var(--rec-len, 5) * .62))); }
.dl-rec-k { max-width: 62ch; font-size: 14px; line-height: 1.5; color: var(--body); overflow-wrap: anywhere; }
.dl-rec-v:empty, .dl-rec-k:empty, .dl-strip:empty, .dl-stats:empty { display: none; }

/* ------------------------------------------------------------------ the hour strip */

.dl-strip { display: grid; gap: 8px; min-width: 0; }
.dl-strip-k { font: 600 11px/1.4 var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); overflow-wrap: anywhere; }
.dl-cells { display: flex; gap: 3px; min-width: 0; height: 44px; }
/* 40 px a cell where there is room; 24 of them still fit a 320 px phone (each shrinks to about 9 px) */
.dl-cell { flex: 0 1 40px; min-width: 0; border-radius: 4px; transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.dl-cell.is-a { background: var(--orange); }
.dl-cell.is-b { background: var(--ink); }
.dl-cell.is-tie { background: var(--sand-2); }
.dl-cell:hover, .dl-cell:focus-visible { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); outline: none; }
.dl-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.dl-key-item { display: inline-flex; align-items: center; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.dl-swatch { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.dl-swatch.is-a { background: var(--orange); }
.dl-swatch.is-b { background: var(--ink); }
.dl-swatch.is-tie { background: var(--sand-2); }
@media (prefers-reduced-motion: reduce) { .dl-cell { transition: none; } }

/* ------------------------------------------------------------------ the means */

.dl-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 20px; margin: 0; border-top: 1px solid var(--amber-soft); }
.dl-stats .stat, .dl-stats .stat:first-child { align-content: start; padding-top: 14px; } /* app.css drops the first one's on phones */
.dl-stats .stat dd { display: grid; gap: 2px; }
.dl-stats .stat dt, .dl-stats .stat-sub { overflow-wrap: anywhere; }
@media (max-width: 1000px) { .dl-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .dl-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ------------------------------------------------------------------ calibration */

.dl-cal { margin-top: clamp(40px, 6vw, 72px); }
.dl-cal[hidden] { display: none; }
.dl-cal-grid { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 24px clamp(24px, 4vw, 48px); align-items: start; }
.dl-cal-chart { min-width: 0; padding: 16px; border-radius: var(--r-md); background: var(--paper); border: 1px solid var(--line); }
.dl-cal-chart .cal { max-width: none; }
.dl-cal-side { display: grid; gap: 14px; min-width: 0; align-content: start; }
.dl-cal-lede { font: 600 clamp(18px, 2.2vw, 22px)/1.35 var(--display); letter-spacing: -.01em; color: var(--ink); text-wrap: balance; }
.dl-cal-stats { margin: 0; border-top: 1px solid var(--amber-soft); }
.dl-cal-stats .stat, .dl-cal-stats .stat:first-child { align-content: start; padding-top: 14px; }
.dl-cal-stats .stat dd { display: grid; gap: 2px; }
.dl-cal-stats .stat dt, .dl-cal-stats .stat-sub { overflow-wrap: anywhere; }
.dl-cal-how { font-size: 12.5px; line-height: 1.55; color: var(--muted); max-width: 60ch; }
@media (max-width: 900px) { .dl-cal-grid { grid-template-columns: minmax(0, 1fr); } .dl-cal-chart { max-width: 520px; } }
@media (max-width: 520px) { .dl-cal-chart { padding: 12px 8px; } }

/* ------------------------------------------------------------------ the picker */

.dl-pick { display: grid; gap: 14px; margin-top: clamp(40px, 6vw, 72px); margin-bottom: clamp(48px, 7vw, 80px); padding-top: clamp(28px, 4vw, 40px); border-top: 1px solid var(--line); }
.dl-pick.is-open { margin-top: clamp(22px, 3vw, 32px); padding-top: 0; border-top: 0; }
.dl-pick .yours-head { margin-bottom: 0; }
.dl-pick-lede { max-width: 62ch; font-size: 14px; line-height: 1.55; color: var(--body); }
.dl-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.dl-field { display: grid; gap: 6px; flex: 1 1 200px; min-width: 0; max-width: 280px; }
.dl-field .input { width: 100%; min-width: 0; }
.dl-form-vs { padding-bottom: 13px; font: 600 12px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dl-go { height: 44px; }
.dl-pick-msg { font-size: 13px; color: var(--bad); }
.dl-pick-msg:empty { display: none; }
.dl-tops { display: grid; gap: 10px; }
.dl-tops:empty { display: none; }
.dl-tops-k { font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.dl-tops-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.dl-tops-list li { min-width: 0; max-width: 100%; }
.dl-top { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; max-width: 100%; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); transition: border-color .2s var(--ease), background-color .2s var(--ease); }
.dl-top:hover { border-color: var(--amber); background: var(--cream); }
.dl-top-name { min-width: 0; font: 600 13.5px/1.2 var(--mono); overflow-wrap: anywhere; }
.dl-top-mean { font: 500 12.5px/1.2 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) {
  .dl-field { flex: 1 1 100%; max-width: none; }
  .dl-form-vs { padding-bottom: 0; }
  .dl-go { flex: 1 1 100%; }
}
