/* BBC — Bow Babysitting Club. Teletext on a test card. Eight colours, true black. */

@font-face { font-family: "Bedstead"; src: url("fonts/bedstead.otf") format("opentype"); font-display: swap; }
@font-face { font-family: "Bedstead"; font-weight: 700; src: url("fonts/bedstead-bold.otf") format("opentype"); font-display: swap; }
@font-face { font-family: "Bedstead Condensed"; src: url("fonts/bedstead-condensed.otf") format("opentype"); font-display: swap; }

:root {
  /* The page is already dark: stop phones in dark mode from recolouring it. */
  color-scheme: dark only;
  --k: #000; --r: #f00; --g: #0f0; --y: #ff0; --b: #00f; --m: #f0f; --c: #0ff; --w: #fff;
  --p: 4px; /* one "pixel" for cut corners */
  --corners: polygon(0 var(--p), var(--p) var(--p), var(--p) 0, calc(100% - var(--p)) 0,
    calc(100% - var(--p)) var(--p), 100% var(--p), 100% calc(100% - var(--p)),
    calc(100% - var(--p)) calc(100% - var(--p)), calc(100% - var(--p)) 100%, var(--p) 100%,
    var(--p) calc(100% - var(--p)), 0 calc(100% - var(--p)));
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: #000; }
body {
  margin: 0;
  min-height: 100vh;
  background: #000;
  color: var(--w);
  font-family: "Bedstead", ui-monospace, monospace;
  font-size: 20px;
  line-height: 1.3;
  padding: 0 0 env(safe-area-inset-bottom);
}
@media (max-width: 600px) { body { font-size: 16px; } }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
p { margin: 0; }

/* teletext colours */
.w { color: var(--w); } .y { color: var(--y); } .c { color: var(--c); } .g { color: var(--g); }
.m { color: var(--m); } .r { color: var(--r); } .b { color: var(--b); }
.bg-r { background: var(--r); color: #000; } .bg-g { background: var(--g); color: #000; }
.bg-y { background: var(--y); color: #000; } .bg-m { background: var(--m); color: #000; }
.bg-w { background: var(--w); color: #000; }
.right { margin-left: auto; display: inline-flex; align-items: center; gap: 1ch; }
.small { font-size: .85em; }

/* pixel corners */
.px, .btn, .badge, .flash, .chip, .bar { clip-path: var(--corners); }
.px-box { clip-path: var(--corners); box-shadow: inset 0 0 0 var(--p) var(--w); }
svg.px { display: block; image-rendering: pixelated; }

/* double height, like the real thing */
.dh {
  display: inline-block;
  transform: scaleY(2);
  transform-origin: top left;
  line-height: 1;
  margin-bottom: 1em;
}
.title { display: block; font-weight: 700; margin: 4px 0 1.3em; }

.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { visibility: hidden; } }

/* --- test card frame ----------------------------------------------------- */
.testcard { max-width: 820px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 1; }
.tc-bars { display: flex; height: 20px; }
.tc-bars i { flex: 1; }
.tc-bars i:nth-child(1) { background: var(--w); } .tc-bars i:nth-child(2) { background: var(--y); }
.tc-bars i:nth-child(3) { background: var(--c); } .tc-bars i:nth-child(4) { background: var(--g); }
.tc-bars i:nth-child(5) { background: var(--m); } .tc-bars i:nth-child(6) { background: var(--r); }
.tc-bars i:nth-child(7) { background: var(--b); } .tc-bars i:nth-child(8) { background: #000; box-shadow: inset 0 0 0 2px #222; }

.tc-body { display: flex; flex: 1; }
.tc-bars, .tc-foot { flex: none; }
.castle { flex: none; width: 14px; background: repeating-linear-gradient(#fff 0 14px, #000 14px 28px); }
.castle:last-child { background-position: 0 14px; }
.page { flex: 1; min-width: 0; padding: 6px 14px 10px; background: #000; display: flex; flex-direction: column; }
.content { flex: 1; }

.tc-foot { display: grid; grid-template-columns: 1fr 1fr; height: 22px; }
.greys { display: flex; }
.greys i { flex: 1; }
.greys i:nth-child(1) { background: #000; } .greys i:nth-child(2) { background: #333; }
.greys i:nth-child(3) { background: #666; } .greys i:nth-child(4) { background: #999; }
.greys i:nth-child(5) { background: #ccc; } .greys i:nth-child(6) { background: #fff; }
.gratings { display: flex; }
.gratings i { flex: 1; }
.gratings i:nth-child(1) { background: repeating-linear-gradient(90deg, #fff 0 6px, #000 6px 12px); }
.gratings i:nth-child(2) { background: repeating-linear-gradient(90deg, #fff 0 4px, #000 4px 8px); }
.gratings i:nth-child(3) { background: repeating-linear-gradient(90deg, #fff 0 3px, #000 3px 6px); }
.gratings i:nth-child(4) { background: repeating-linear-gradient(90deg, #fff 0 2px, #000 2px 4px); }
.gratings i:nth-child(5) { background: repeating-linear-gradient(90deg, #fff 0 1px, #000 1px 2px); }

@media (max-width: 600px) {
  .castle { width: 7px; background: repeating-linear-gradient(#fff 0 10px, #000 10px 20px); }
  .castle:last-child { background-position: 0 10px; }
  .page { padding: 4px 8px 8px; }
  .tc-bars { height: 12px; }
  .tc-foot { height: 14px; }
}

/* --- header -------------------------------------------------------------- */
.tt-header { display: flex; gap: 1ch; white-space: nowrap; overflow: hidden; padding: 2px 0 8px; }
.clock { margin-left: auto; }

.masthead { display: flex; align-items: center; gap: 14px; }
.club-name { color: var(--c); font-weight: 700; margin: 0; transform-origin: center left; }
@media (max-width: 600px) { .masthead svg.logo { width: 87px; height: 36px; } }

.ticker {
  display: flex; gap: 1ch; align-items: center;
  margin: 12px 0 14px;
  background: var(--b);
  padding: 3px 6px;
  white-space: nowrap; overflow: hidden;
  clip-path: var(--corners);
}
.ticker-label { color: var(--y); }
.ticker-label::after { content: " ▶"; }
.ticker-text { color: var(--w); overflow: hidden; text-overflow: ellipsis; font-family: "Bedstead Condensed", "Bedstead", monospace; }
.ticker-label { font-family: "Bedstead Condensed", "Bedstead", monospace; }
.ticker-label .short { display: none; }
@media (max-width: 600px) {
  .ticker-label .long { display: none; }
  .ticker-label .short { display: inline; }
  .ticker { gap: .6ch; }
}

/* --- bits ---------------------------------------------------------------- */
.bar { display: block; padding: 3px 6px; margin: 18px 0 8px; font-size: 1em; font-weight: 400; }
.bar-b { background: var(--b); color: var(--y); }
.bar-r { background: var(--r); color: var(--w); margin-top: 0; }
.bar-y { background: var(--y); color: #000; }
.bar-g { background: var(--g); color: #000; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 1ch;
  padding: 8px 14px;
  border: 0;
  background: var(--w); color: #000;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--c); color: #000; }
.btn:active { transform: translate(2px, 2px); }
.btn:focus-visible { box-shadow: inset 0 0 0 3px #000, inset 0 0 0 6px var(--w); outline: none; }
.btn-y { background: var(--y); } .btn-g { background: var(--g); } .btn-r { background: var(--r); color: var(--w); }
.btn-b { background: var(--b); color: var(--w); } .btn-w { background: var(--w); }
.btn-sm { padding: 3px 8px; }
.btn.chosen { box-shadow: inset 0 0 0 3px #000; }
.btn.chosen::before { content: "▶"; }

.flash { background: var(--b); color: var(--w); padding: 3px 6px; margin-bottom: 12px; }

/* --- login --------------------------------------------------------------- */
body.door { background: #000; }
body.door .testcard { min-height: 0; margin-top: 8vh; max-width: 560px; }
.door { text-align: center; padding: 30px 0 20px; position: relative; z-index: 1; }
.door-logo svg { margin: 0 auto; max-width: 100%; height: auto; }
.door-title { color: var(--c); font-weight: 700; margin: 18px 0 1.6em; transform-origin: top center; }
.door-form { display: grid; gap: 12px; justify-items: center; }
.code-input {
  width: min(100%, 260px); padding: 10px; border: 0;
  background: #000; color: var(--g); text-align: center; font-size: 1.6em; letter-spacing: .3em;
  caret-color: var(--g);
}
.code-input:focus { outline: none; box-shadow: inset 0 0 0 var(--p) var(--y); }
.no-signal { background: var(--r); color: var(--w); padding: 2px 10px; animation: blink .5s steps(1) 4; }

/* --- who ----------------------------------------------------------------- */
.who-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.who-btn {
  display: grid; place-items: center;
  padding: 34px 10px; font-weight: 700; font-size: 1.15em;
  border: 0; cursor: pointer;
  background: var(--f); color: #000;
}
.who-btn:hover { background: var(--w); }

/* --- month --------------------------------------------------------------- */
.month-head { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 10px; }
.month-head .title { text-align: center; transform-origin: top center; margin-bottom: 1.2em; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; color: var(--c); background: var(--b); padding: 2px 0; }
.cal-day {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  min-height: 78px; padding: 6px;
  background: #000;
  box-shadow: inset 0 0 0 2px var(--b);
}
.cal-day:hover, .cal-day:focus-visible { box-shadow: inset 0 0 0 3px var(--y); outline: none; }
.cal-day.weekend .cal-num { color: var(--y); }
.cal-day.other { opacity: .3; }
.cal-day.past { opacity: .55; }
.cal-day.today { box-shadow: inset 0 0 0 3px var(--g); }
.cal-day.today .cal-num { background: var(--g); color: #000; padding: 0 3px; }

/* pixel markers: O = request, + = offer, in the family's colour */
.marks { display: flex; flex-wrap: wrap; gap: 4px; }
.mark { display: inline-flex; color: var(--f); }
.mark.nope { opacity: .35; }
.slow-flash { animation: slow-flash 2.4s steps(1) infinite; }
@keyframes slow-flash { 60% { opacity: 0; } }

/* booked: the whole square turns the sitter's colour */
.cal-day.booked { background: var(--s); box-shadow: none; color: #000; }
.cal-day.booked .cal-num { color: #000; }
.cal-day.booked:hover, .cal-day.booked:focus-visible { box-shadow: inset 0 0 0 3px #000, inset 0 0 0 5px var(--w); }
.cal-day.booked.today { box-shadow: inset 0 0 0 3px var(--g); }
.cal-day.booked.past { opacity: .7; }
.cal-sitting { margin-top: auto; font-weight: 700; font-size: 1.4em; line-height: 1; }

@media (max-width: 600px) {
  .cal { gap: 2px; }
  .cal-day { min-height: 58px; padding: 3px; gap: 2px; --p: 2px; }
  .mark svg { width: 14px; height: 14px; }
  .marks { gap: 2px; }
  .cal-sitting { font-size: 1.1em; }
  .tt-date { display: none; }
}

/* families are colours */
.sw { display: inline-block; width: .8em; height: .8em; background: var(--f); flex: none; vertical-align: middle; }
.sw-big { width: 1em; height: 1em; }
.fam { display: inline-flex; align-items: center; gap: .7ch; color: var(--f); }
.key { margin-top: 10px; display: grid; gap: 8px; }
.key p { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.key p > span { display: inline-flex; align-items: center; gap: 1ch; }


.listing { display: grid; gap: 4px; }
.listing li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.listing-row { flex: 1 1 240px; display: flex; align-items: center; gap: 1ch; padding: 3px 4px; min-height: 30px; }
.listing-row:hover { background: var(--b); }
.quick { display: flex; gap: 4px; }
.newsflash { margin-bottom: 16px; }

.empty { text-align: center; padding: 12px 0; }
.mini-card svg { margin: 0 auto 12px; max-width: 100%; height: auto; }

/* --- day ----------------------------------------------------------------- */
.prog { background: #000; box-shadow: inset 0 0 0 var(--p) var(--f); padding: 12px; margin-bottom: 12px; }
.prog-head { display: flex; align-items: center; gap: 1ch; }
.facts { display: grid; grid-template-columns: 7ch 1fr; gap: 4px 1ch; margin: 10px 0 0; }
.facts dt { color: var(--c); }
.facts dd { margin: 0; }
.badge { padding: 2px 6px; white-space: nowrap; }
.note { margin-top: 10px; }
.answers { display: grid; gap: 4px; margin-top: 10px; }
.answers li { display: flex; align-items: center; gap: 1ch; flex-wrap: wrap; }
.answers b { margin-left: auto; font-weight: 400; }
.yes-no { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.yes-no-q { flex-basis: 100%; }
.yes-no .btn { flex: 1; padding: 10px; }
.yes-no .btn-sm { flex: 0; }
.edit { margin-top: 10px; }
.edit summary { cursor: pointer; }
.edit form + form { margin-top: 8px; }

.tt-form { display: grid; gap: 10px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row label { display: flex; align-items: center; gap: 1ch; color: var(--c); }
.tt-form input[type=time], .tt-form input[type=text] {
  border: 0; background: #000; color: var(--g); padding: 8px 10px; color-scheme: dark; caret-color: var(--g);
}
.tt-form input[type=text] { width: 100%; }
.tt-form input::placeholder { color: var(--b); }
.tt-form input:focus { outline: none; box-shadow: inset 0 0 0 var(--p) var(--y); }
.tt-form > .btn { justify-self: start; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { position: relative; display: inline-flex; align-items: center; gap: 1ch; padding: 6px 10px; cursor: pointer; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill:has(input:checked) { background: var(--y); color: #000; box-shadow: none; }
.pill:has(input:focus-visible) { box-shadow: inset 0 0 0 var(--p) var(--c); }

/* --- ratings ------------------------------------------------------------- */
.ratings { display: grid; gap: 12px; }
.rating { background: #000; box-shadow: inset 0 0 0 var(--p) var(--f); padding: 12px; display: grid; gap: 6px; }
.rating-head { display: flex; align-items: center; gap: 1ch; flex-wrap: wrap; margin-bottom: 4px; }
.pos { color: var(--f); font-weight: 700; margin-bottom: 0; transform-origin: center; }
.meter { display: grid; grid-template-columns: 4ch 1fr 3ch; gap: 1ch; align-items: center; }
.meter b { text-align: right; font-weight: 400; }
.track { display: flex; gap: 3px; flex-wrap: wrap; min-height: 14px; }
.track i { width: 10px; height: 14px; background: var(--f); }
.track.alt i { background: repeating-linear-gradient(45deg, var(--f) 0 3px, #000 3px 5px); }

/* --- fastext ------------------------------------------------------------- */
.fastext { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1ch; margin-top: 22px; }
.fastext a { display: flex; align-items: center; justify-content: center; gap: 1ch; padding: 4px 0; white-space: nowrap; }
.fastext a.r { color: var(--r); } .fastext a.g { color: var(--g); }
.fastext a.y { color: var(--y); } .fastext a.c { color: var(--c); }
.fastext a:hover { background: var(--w); color: #000; }

/* --- static, only when changing channel -------------------------------- */
.snow {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 40;
  opacity: 0;
  image-rendering: pixelated;
}
.snow.loud { opacity: .95; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .snow { display: none; }
}

/* --- request / offer ----------------------------------------------------- */
.actions { display: grid; gap: 10px; margin-top: 18px; }
.action > summary { list-style: none; display: flex; justify-content: flex-start; gap: 2ch; padding: 12px 14px; font-weight: 700; }
.action > summary::-webkit-details-marker { display: none; }
.action > summary::after { content: "▼"; margin-left: auto; }
.action[open] > summary::after { content: "▲"; }
.action > summary small { font-weight: 400; font-size: 1em; }
.action > summary svg { flex: none; }
.action > .tt-form { padding: 12px 0 6px; }
.hint { font-size: .85em; color: var(--w); }
