/* Chart for the Day: a school timetable card. Square corners throughout. */

:root { --head: var(--c-earth); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --head: var(--ink); }
}
[data-theme="dark"] { --head: var(--ink); }

.t0 { --tint: color-mix(in srgb, var(--c-peach) 55%, #FCF0DD); }
.t1 { --tint: color-mix(in srgb, var(--c-sky) 55%, #FCF0DD); }
.t2 { --tint: color-mix(in srgb, var(--c-mustard) 55%, #FCF0DD); }
.t3 { --tint: color-mix(in srgb, var(--c-lavlt) 55%, #FCF0DD); }
.t4 { --tint: color-mix(in srgb, var(--c-teal) 55%, #FCF0DD); }

* { box-sizing: border-box; border-radius: 0; }
html, body { background: var(--bg); }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  line-height: 1.45;
}
main { max-width: 980px; margin: 0 auto; padding: 28px 16px 56px; }
[hidden] { display: none !important; }
p { margin: 0; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
h1 { color: var(--head); font-size: 30px; line-height: 1.15; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.bar { display: block; width: 56px; height: 4px; margin-top: 10px; background: var(--c-brick); }
.mark { display: inline-block; background: #FCF0DD; padding: 4px; line-height: 0; flex: none; }
.mark img { height: 28px; width: auto; display: block; }
.mark.small img { height: 18px; }

/* the form, ruled like a request slip */
.lead { margin: 22px 0 18px; max-width: 46em; }
.slip { border: 1px solid var(--ink); max-width: 720px; }
.f { display: block; padding: 10px 12px 12px; border-bottom: 1px solid var(--ink); }
.f:last-child { border-bottom: 0; }
.l { display: block; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 4px; }
.help { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.three { display: grid; grid-template-columns: 2fr 1fr 1fr; border-bottom: 1px solid var(--ink); }
.three .f { border-bottom: 0; border-right: 1px solid var(--ink); }
.three .f:last-child { border-right: 0; }
input, textarea, button { font: inherit; color: inherit; border-radius: 0; }
input, textarea {
  display: block; width: 100%;
  border: 1px solid var(--ink); background: transparent;
  padding: 6px 8px; appearance: none; -webkit-appearance: none;
}
textarea { resize: vertical; }
.submit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
#alert { color: var(--error); }
#alert:empty { display: none; }

button { cursor: pointer; padding: 9px 16px; border: 1px solid var(--ink); appearance: none; -webkit-appearance: none; }
.fill { background: #530E36; color: #FCF0DD; }
.out { background: transparent; color: var(--ink); min-width: 44px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* the sheet */
.sheethead { margin: 18px 0 16px; }
#s-date { font-weight: 700; }
.wrap { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; }
#timetable { width: 100%; min-width: 620px; }
#timetable th, #timetable td { border: 1px solid var(--ink); padding: 6px 8px; text-align: left; vertical-align: top; }
#timetable thead th { color: var(--head); border-bottom: 3px double var(--ink); font-size: 13px; }
#timetable td:nth-child(-n+4), #timetable th:nth-child(-n+4) { white-space: nowrap; }
#timetable tr[class^="t"] td:not(.m) { background: var(--tint); color: #1A1A1A; }
#timetable td.m { color: var(--ink-soft); font-size: 12.5px; width: 46%; }
.m .fig { float: left; width: 46px; height: 38px; margin: 2px 10px 2px 0; }
.fig rect { fill: currentColor; }
.fig .mk { fill: none; stroke: currentColor; stroke-width: 1.4; }
.note { display: block; overflow: hidden; }
tr.pending td { color: var(--ink-soft); }

#totals { margin: 14px 0 0; }
#totals p { margin: 2px 0; }

#panel { border: 1px solid var(--ink); padding: 12px; margin: 18px 0 0; max-width: 720px; }
#panel p + p { margin-top: 4px; }
.keys { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
#p-status { min-height: 1.45em; color: var(--ink-soft); }
.controls { display: flex; gap: 8px; margin: 18px 0 0; }

/* the back of the card */
.back { margin-top: 40px; }
#chart { min-width: 480px; width: 100%; table-layout: fixed; }
#chart td { border: 1px solid var(--ink); padding: 0; height: 64px; position: relative; vertical-align: top; }
#chart td[class^="t"] { background: var(--tint); color: #1A1A1A; }
#chart span { position: absolute; font-size: 11px; line-height: 1; }
#chart .n { top: 4px; left: 5px; }
#chart .c { top: 50%; left: 0; right: 0; text-align: center; transform: translateY(-50%); font-size: 18px; font-weight: 700; }
#chart .rest .c { font-size: 14px; font-weight: 400; }
#chart .len { bottom: 4px; left: 5px; }
#chart .hits { bottom: 4px; right: 5px; font-weight: 700; }
#legend { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 4px 16px; }
#legend li { display: flex; gap: 8px; align-items: baseline; }
#legend b { display: inline-block; width: 1.6em; text-align: center; background: var(--tint); color: #1A1A1A; }
#legend li.rest::before { content: ""; display: inline-block; width: 1.6em; }
#colophon { margin-top: 22px; font-size: 12px; color: var(--ink-soft); max-width: 46em; }
#colophon p { margin: 1px 0; }
#colophon .mark { margin-top: 10px; }

@media (max-width: 600px) {
  h1 { font-size: 24px; }
  .mark img { height: 22px; }
  .three { grid-template-columns: 1fr 1fr; }
  .three .f:first-child { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--ink); }
}

@page { size: A4; margin: 12mm; }

@media print {
  body { font-size: 10pt; }
  main { max-width: none; padding: 0; }
  #form-view, #panel, .controls, #print, #again, tr.pending { display: none !important; }
  .wrap { overflow: visible; }
  #timetable, #chart { min-width: 0; }
  thead { display: table-header-group; }
  tr, #chart, #legend li { break-inside: avoid; }
  .back { break-before: page; margin-top: 0; }
  #timetable td.m { font-size: 7.5pt; }
  .m .fig { width: 12mm; height: 10mm; }
  #chart td { height: 21mm; }
  #timetable tr[class^="t"] td, #chart td, #legend b, .mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media print {
  :root, :root:not([data-theme="light"]), [data-theme="dark"] {
    --head: var(--c-earth);
    --ink: #1A1A1A;
    --ink-soft: #5B5B5B;
    --error: #BE3B27;
    --bg: transparent;
    color-scheme: light;
  }
}
