/* Pens Down. Two halves: the form a teacher fills in, and the stage that goes
   on the board.

   Everything inside .pd is styled here rather than borrowing from site.css,
   because the Save a copy button writes this file into a single page that has
   to work on its own from a USB stick, with no site around it.

   The stage sizes itself from --pd-u, which the script keeps at one hundredth
   of the stage's width. Nothing here is in pixels that matter, so the same
   rules serve a small preview on this page and a projector at the front of a
   hall. Colours arrive the same way: the script works out the shades from the
   school's three and sets them as properties. */

/* Everything in here is laid out with grid or flex, and an author display
   beats the browser's own [hidden] rule. Without this line the script hides a
   field and the field stays on screen, which is how both halves of the time
   section came to be visible at once. One rule, rather than remembering to
   write another the next time something gets a display. */
.pd[hidden], .pd [hidden] { display: none !important; }
.pd-notice { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 16px 20px; }

/* What the page is for, said before the form rather than after it. A teacher
   arriving for the first time should know what they are filling in and why
   before they start typing, and should not have to reach the bottom of the
   page to be told nothing leaves their computer. */
.pd-intro { background: var(--surface); border: 1px solid var(--card-line); border-radius: 14px;
  border-inline-start: 7px solid var(--accent); padding: 22px 26px 24px; margin-block-end: 28px;
  box-shadow: 0 2px 4px rgba(11, 27, 61, .07), 0 16px 30px -26px rgba(11, 27, 61, .5); }
.pd-intro h2 { margin: 0 0 16px; font-size: 1.5rem; }
.pd-intro-lead { margin: 0 0 22px; font-size: 1.08rem; color: var(--ink); max-width: 60ch; }
.pd-intro-points { display: grid; gap: 20px 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.pd-intro-points p { margin: 0; font-size: .95rem; line-height: 1.6; color: var(--muted); padding-block-start: 14px;
  border-block-start: 2px solid var(--card-line); }
@media (max-width: 680px) {
  .pd-intro { padding: 18px 18px 20px; border-inline-start-width: 5px; }
  .pd-intro h2 { font-size: 1.3rem; }
}

/* ---------- the form ---------- */

/* Built out of the site's own colour tokens rather than fixed colours, so it
   follows the page into dark mode instead of staying stubbornly cream. The
   depth is the point: a panel with a solid cap, and fields sunk into it, so a
   teacher can see at a glance what is a heading and what is a box to type in. */

.pd-setup { display: grid; gap: 28px; max-width: 980px; }

.pd-step { background: var(--surface); border: 1px solid var(--card-line); border-radius: 14px;
  padding: 0 26px 28px; overflow: hidden;
  box-shadow: 0 3px 5px rgba(11, 27, 61, .10), 0 22px 40px -26px rgba(11, 27, 61, .55); }
.pd-step h2 { display: flex; align-items: center; gap: 14px; margin: 0 -26px 24px; padding: 16px 26px;
  background: var(--chrome); color: var(--chrome-ink); font-size: 1.06rem;
  border-block-end: 3px solid var(--accent); }
.pd-step h2 .n { width: 30px; height: 30px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-size: .92rem; font-weight: 700;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 2px 5px rgba(0, 0, 0, .35); }

/* Rows line up because every label takes the same height whether it wraps or
   not, and the two halves of the school section are equal. */
.pd-grid { display: grid; gap: 16px 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.pd-grid.one { grid-template-columns: minmax(0, 1fr); max-width: calc(50% - 10px); }
.pd-grid + .pd-grid { margin-block-start: 16px; }
.pd .field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.pd .field label { font-weight: 700; font-size: .82rem; letter-spacing: .04em; color: var(--muted); min-height: 1.35em; }
.pd .field input, .pd .field select { font: inherit; width: 100%; padding: 13px 14px;
  border: 1px solid var(--field-line); border-radius: 8px; background: var(--bg); color: var(--ink);
  box-shadow: inset 0 3px 6px rgba(11, 27, 61, .15), inset 0 -1px 0 rgba(255, 255, 255, .55); }
.pd .field input:focus-visible, .pd .field select:focus-visible { outline: none; border-color: var(--focus);
  box-shadow: inset 0 2px 5px rgba(11, 27, 61, .10), 0 0 0 4px var(--glow, rgba(201, 162, 74, .4)); }
.pd-opt { font-weight: 400; color: var(--muted); font-size: .88em; text-transform: none; letter-spacing: 0; }
.pd-hint { color: var(--muted); font-size: .92rem; margin: 10px 0 0; max-width: 62ch; }
.pd-error { background: #FDECEC; border: 1px solid #C0392B; color: #7D241B; border-radius: 8px; padding: 12px 16px; margin: 0; }

.pd-choice, .pd-layouts { display: grid; gap: 10px; margin-block-end: 16px; }
.pd-layouts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pd .check { display: flex; gap: 11px; align-items: flex-start; padding: 15px 17px;
  border: 1px solid var(--field-line); border-radius: 10px; background: var(--surface); cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 4px 9px -6px rgba(11, 27, 61, .5); }
.pd .check input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.pd .check b { display: block; }
.pd .check small { display: block; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.pd .check:has(input:checked) { background: var(--chrome); color: var(--chrome-ink); border-color: var(--chrome);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .14), 0 8px 16px -9px rgba(11, 27, 61, .8); }
.pd .check:has(input:checked) small { color: var(--chrome-muted); }
.pd .check:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.pd-brand { display: grid; gap: 28px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.pd-logo-pick, .pd-colours { display: flex; flex-direction: column; }
.pd-logo-pick > .pd-hint, .pd-colours > .pd-hint { margin-block-start: auto; padding-block-start: 12px; }
.pd-colour-head { font-weight: 700; margin: 0 0 10px; }
.pd-step > .pd-colour-head:not(:first-of-type) { margin-block-start: 26px; }
.pd-step .pd-colour-head + .pd-hint { margin-block-start: -4px; margin-block-end: 14px; }
.pd-swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-block-end: 14px; }
.pd-swatch { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; color: var(--muted); }
.pd-swatch input[type="color"] { width: 100%; height: 52px; padding: 3px; cursor: pointer;
  border: 1px solid var(--field-line); border-radius: 8px; background: var(--bg);
  box-shadow: inset 0 3px 6px rgba(11, 27, 61, .28); }
.pd-hex { width: 100%; font: inherit; font-size: .82rem; text-align: center; padding: 7px 2px;
  border: 1px solid var(--field-line); border-radius: 6px; background: var(--bg); color: var(--ink);
  text-transform: uppercase; box-shadow: inset 0 2px 4px rgba(11, 27, 61, .14); }
.pd-logo-preview { display: flex; align-items: center; gap: 14px; margin-block-start: 14px; }
.pd-logo-preview img { max-width: 110px; max-height: 110px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }

.pd .btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border: 1px solid var(--ink); border-radius: 8px; background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 3px 0 var(--card-line); }
.pd .btn:hover { background: var(--accent-soft); }
.pd .btn.primary { background: var(--chrome); color: var(--chrome-ink); border-color: var(--chrome);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 4px 0 var(--link); }
.pd .btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 1px 0 var(--card-line); }
.pd .btn.pd-small { padding: 9px 15px; font-size: .9rem; }
.pd .btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pd-go { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.pd-keep { background: var(--bg); }
.pd-keep > p:first-of-type { color: var(--muted); margin: 0 0 14px; }

.pd-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.pd-theme { border: 1px solid var(--field-line); border-radius: 10px; padding: 0; cursor: pointer; background: none;
  overflow: hidden; text-align: left; box-shadow: 0 4px 0 var(--card-line), 0 10px 18px -12px rgba(11, 27, 61, .6); }
.pd-theme[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 4px 0 var(--link), 0 12px 20px -12px rgba(11, 27, 61, .7); }
.pd-theme:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* Spans, so each one needs telling to be a block: left inline, the colour
   paints only behind the words and the rule under them collapses to a sliver
   down the left-hand edge. */
.pd-theme .t-face, .pd-theme .t-rule, .pd-theme .t-name { display: block; }
.pd-theme .t-face { padding: 16px 10px 14px; text-align: center; }
.pd-theme .t-num { font-weight: 700; font-size: 1.5rem; letter-spacing: -.02em; display: block; }
.pd-theme .t-rule { height: 7px; }
.pd-theme .t-name { padding: 7px 10px; font-size: .82rem; background: var(--bg); color: var(--muted); text-align: center; }

@media (max-width: 680px) {
  .pd-grid, .pd-grid.one, .pd-brand, .pd-layouts { grid-template-columns: minmax(0, 1fr); max-width: none; }
  .pd-step { padding: 0 16px 22px; }
  .pd-step h2 { margin: 0 -16px 20px; padding: 14px 16px; }
}

/* ---------- the stage ---------- */

.pd-stage {
  --pd-u: 1vw;
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden;
  border: 1px solid var(--card-line); border-radius: var(--radius);
  background: var(--pd-bg, #F7F5EF); color: var(--pd-fg, #11261A);
  --pd-big: 18.5; --pd-fit: 1;
  font-family: inherit; display: flex; flex-direction: column;
  margin-block-end: 18px;
}
.pd-stage:fullscreen { aspect-ratio: auto; height: 100%; border: 0; border-radius: 0; margin: 0; }
.pd-stage:-webkit-full-screen { aspect-ratio: auto; height: 100%; border: 0; border-radius: 0; }
.pd-stage .num { font-family: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.pd-top { display: flex; align-items: center; gap: calc(var(--pd-u) * 1.6);
  padding: calc(var(--pd-u) * 1.6) calc(var(--pd-u) * 3);
  background: var(--pd-band-bg); color: var(--pd-band-fg);
  border-block-end: calc(var(--pd-u) * .45) solid var(--pd-accent); }
.pd-logo { width: auto; height: calc(var(--pd-u) * 5.2); max-width: calc(var(--pd-u) * 13); object-fit: contain; flex: none; }
.pd-ident { min-width: 0; }
.pd-school { font-size: calc(var(--pd-u) * 1.9); font-weight: 700; line-height: 1.12; }
.pd-sub { font-size: calc(var(--pd-u) * 1.2); opacity: .82; letter-spacing: .06em; text-transform: uppercase; margin-top: calc(var(--pd-u) * .3); }
.pd-meta { margin-inline-start: auto; text-align: end; font-size: calc(var(--pd-u) * 1.45); opacity: .9; line-height: 1.45; flex: none; }

.pd-mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; padding: calc(var(--pd-u) * 1.5) calc(var(--pd-u) * 2); }
.pd-paper { font-size: calc(var(--pd-u) * 2.5); font-weight: 700; text-align: center; line-height: 1.2; }
.pd-ringwrap { position: relative; display: grid; place-items: center; }
.pd-ring { display: none; }
.pd-ring-track { stroke: var(--pd-track); }
.pd-ring-live { stroke: var(--pd-accent); transition: stroke-dashoffset .4s linear; }
.pd-clockbox { text-align: center; }
.pd-label { font-size: calc(var(--pd-u) * 1.6); letter-spacing: .2em; text-transform: uppercase; color: var(--pd-dim); font-weight: 600; }
.pd-big { font-size: calc(var(--pd-u) * var(--pd-big) * var(--pd-fit)); font-weight: 700; line-height: .92; white-space: nowrap; }
.pd-stage[data-len="7"] { --pd-fit: .72; }
.pd-stage[data-len="8"] { --pd-fit: .63; }
.pd-note { font-size: calc(var(--pd-u) * 1.5); color: var(--pd-dim); margin-top: calc(var(--pd-u) * .6); min-height: 1.2em; }

.pd-plates { display: flex; gap: calc(var(--pd-u) * 1.6); margin-top: calc(var(--pd-u) * 1.6); flex-wrap: wrap; justify-content: center; }
.pd-plate { border: calc(var(--pd-u) * .18) solid currentColor; border-radius: calc(var(--pd-u) * 1.1);
  padding: calc(var(--pd-u) * .9) calc(var(--pd-u) * 2.4); text-align: center; min-width: calc(var(--pd-u) * 17); }
.pd-plate b { display: block; font-size: calc(var(--pd-u) * 1.05); letter-spacing: .16em; text-transform: uppercase; color: var(--pd-dim); font-weight: 600; }
.pd-plate span { font-size: calc(var(--pd-u) * 3.8); font-weight: 700; line-height: 1.1; }

/* One quiet line, centred so it never meets the buttons on the right or the
   keyboard note on the left, and in the dimmed colour the school's own
   palette produced rather than a colour of ours. */
.pd-credit { position: absolute; inset-block-end: calc(var(--pd-u) * 2.1); inset-inline: 0; text-align: center;
  font-size: calc(var(--pd-u) * .95); color: var(--pd-dim); margin: 0; letter-spacing: .04em; opacity: .8; }
.pd-stage[data-layout="ring"] .pd-credit { inset-block-end: calc(var(--pd-u) * .9); }
.pd-credit-switch { margin-block-start: 18px; }

.pd-bar { height: calc(var(--pd-u) * 1.35); background: var(--pd-track); flex: none; }
.pd-bar i { display: block; height: 100%; width: 0; background: var(--pd-accent); transition: width .4s linear; }

.pd-controls { position: absolute; inset-block-end: calc(var(--pd-u) * 2.4); inset-inline-end: calc(var(--pd-u) * 2); display: flex; gap: 8px; transition: opacity .2s ease; }
.pd-controls .btn { background: var(--pd-bg); color: var(--pd-fg); border-color: var(--pd-fg); }
.pd-keys { position: absolute; inset-block-end: calc(var(--pd-u) * 2.1); inset-inline-start: calc(var(--pd-u) * 2); font-size: calc(var(--pd-u) * .95); color: var(--pd-dim); margin: 0; opacity: .8; transition: opacity .2s ease; }
/* On the board they are in the way, so they wait until the mouse moves. */
.pd-stage:fullscreen .pd-controls, .pd-stage:fullscreen .pd-keys { opacity: 0; }
.pd-stage:fullscreen:hover .pd-controls, .pd-stage:fullscreen:hover .pd-keys, .pd-stage:fullscreen .pd-controls:focus-within { opacity: 1; }

/* states */
.pd-stage[data-state="warn"] .pd-big, .pd-stage[data-state="final"] .pd-big { color: var(--pd-accent); }
.pd-stage[data-state="final"] .pd-big { animation: pd-beat 1s steps(1) infinite; }
.pd-stage[data-state="paused"] .pd-big, .pd-stage[data-state="paused"] .pd-label { opacity: .45; }
.pd-stage[data-state="over"] .pd-big { color: var(--pd-accent); }
.pd-stage[data-state="over"] .pd-bar i { width: 100% !important; }
@keyframes pd-beat { 0% { opacity: 1; } 50% { opacity: .55; } }
@media (hover: none) {
  .pd-stage:fullscreen .pd-controls { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .pd-stage[data-state="final"] .pd-big { animation: none; }
  .pd-ring-live, .pd-bar i { transition: none; }
}

/* banner is the default above. the other two rearrange it. */

.pd-stage[data-layout="panel"] { flex-direction: row; }
.pd-stage[data-layout="panel"] .pd-top { flex-direction: column; align-items: flex-start; justify-content: flex-start;
  width: 34%; flex: none; height: 100%; gap: calc(var(--pd-u) * 1.4);
  padding: calc(var(--pd-u) * 3.2) calc(var(--pd-u) * 2.6);
  border-block-end: 0; border-inline-end: calc(var(--pd-u) * .55) solid var(--pd-accent); }
.pd-stage[data-layout="panel"] .pd-logo { height: calc(var(--pd-u) * 7.4); }
.pd-stage[data-layout="panel"] .pd-school { font-size: calc(var(--pd-u) * 2.1); }
.pd-stage[data-layout="panel"] .pd-meta { margin-inline-start: 0; text-align: start; font-size: calc(var(--pd-u) * 1.35); }
.pd-stage[data-layout="panel"] .pd-mid { flex: 1; min-width: 0; }
.pd-stage[data-layout="panel"] .pd-paper { font-size: calc(var(--pd-u) * 2.1); }
.pd-stage[data-layout="panel"] { --pd-big: 15.5; }
.pd-stage[data-layout="panel"] .pd-bar { position: absolute; inset-block-end: 0; inset-inline-end: 0; width: 66%; }
.pd-stage[data-layout="panel"] .pd-top .pd-paper { font-size: calc(var(--pd-u) * 1.75); text-align: start; font-weight: 400; line-height: 1.35; }
.pd-stage[data-layout="panel"] .pd-top { overflow: hidden; }
.pd-stage[data-layout="panel"] .pd-top .pd-plates { flex-direction: column; margin-block-start: auto; gap: calc(var(--pd-u) * .8); align-items: stretch; width: 100%; flex-wrap: nowrap; }
.pd-stage[data-layout="panel"] .pd-top .pd-plate { border: 0; border-block-start: calc(var(--pd-u) * .14) solid currentColor; border-radius: 0;
  padding: calc(var(--pd-u) * .7) 0 0; text-align: start; min-width: 0; opacity: .95; }
.pd-stage[data-layout="panel"] .pd-top .pd-plate b { color: inherit; opacity: .72; }
.pd-stage[data-layout="panel"] .pd-top .pd-plate span { font-size: calc(var(--pd-u) * 3.5); }

.pd-stage[data-layout="ring"] .pd-top { background: transparent; color: var(--pd-fg); border-block-end: 0;
  padding: calc(var(--pd-u) * 1.8) calc(var(--pd-u) * 3) 0; }
.pd-stage[data-layout="ring"] .pd-sub, .pd-stage[data-layout="ring"] .pd-meta { color: var(--pd-dim); }
.pd-stage[data-layout="ring"] .pd-ring { display: block; position: absolute; inset: 0; transform: rotate(-90deg); }
.pd-stage[data-layout="ring"] .pd-ringwrap { width: calc(var(--pd-u) * 34); height: calc(var(--pd-u) * 34); margin-block: calc(var(--pd-u) * .4); flex: none; }
.pd-stage[data-layout="ring"] { --pd-big: 11.4; }
.pd-stage[data-layout="ring"][data-len="5"] { --pd-fit: .82; }
.pd-stage[data-layout="ring"][data-len="4"] { --pd-fit: 1; }
.pd-stage[data-layout="ring"] .pd-paper { font-size: calc(var(--pd-u) * 2); margin-top: calc(var(--pd-u) * .7); }
/* Centring happens inside a shorter box, so the times come to rest above
   the buttons rather than underneath them. A margin on the times alone only
   moves them half as far, because the centring takes half of it back. */
.pd-stage[data-layout="ring"] .pd-mid { padding-block: 0 calc(var(--pd-u) * 5); }
.pd-stage[data-layout="ring"] .pd-plates { margin-top: calc(var(--pd-u) * .7); }
.pd-stage[data-layout="ring"] .pd-controls { inset-block-end: calc(var(--pd-u) * .9); }
.pd-stage[data-layout="ring"] .pd-note { display: none; }
.pd-stage[data-layout="ring"] .pd-plate { border: 0; padding-block: 0; }
.pd-stage[data-layout="ring"] .pd-bar { display: none; }

/* On a phone the form is the point: the stage is only a preview, so let it be
   small and let the teacher put it on the board from a computer. */
@media (max-width: 640px) {
  .pd-swatches { gap: 10px; }
  .pd-step { padding: 16px 16px 20px; }
}

/* The saved offline copy has no site around it. */
.pd-solo { max-width: 1400px; margin: 0 auto; padding: 18px; }
.pd-solo .pd-stage { margin-block-end: 14px; }
.pd-solo-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.pd-solo-head h1 { font-size: 1.25rem; margin: 0; }
.pd-solo-head p { margin: 0; color: var(--muted); font-size: .92rem; }
