/* Styled after magpiekids.com: full-width rainbow sections, black "sticker" borders with a
   white halo, pill buttons, black text and Jost. */
:root {
  --red: #fc5f60; --orange: #fdb225; --yellow: #fddf3c;
  --green: #98c76e; --blue: #5cbbda; --purple: #996ad5;
  --purple-dark: color-mix(in srgb, var(--purple) 88%, black);
  --red-dark: color-mix(in srgb, var(--red) 62%, black);
  --tint-closed: color-mix(in srgb, var(--red) 34%, white); /* soft: errors */
  --tint-hours: color-mix(in srgb, var(--orange) 45%, white);
  --tint-note: color-mix(in srgb, var(--blue) 38%, white);
  --page-max: 1380px; /* seven cards of at least 168px at full size, so a repeat badge fits beside "Wednesday" */
  --purple-tint: color-mix(in srgb, var(--purple) 30%, white);
  color-scheme: light;
}
/* Only the day cards scale with the window; everything else keeps its normal size. --u is the
   "card rem": 13px at 1180px wide or less, rising smoothly to the normal 16px at 1380px and wider.
   --vw is the width the page really has (the window minus any scrollbar; set in vw.js), not
   100vw, which includes the scrollbar. From about 1140px up, a week of seven cards fits with 40px
   or more to spare. */
:root { --u: clamp(13px, calc(13px + (var(--vw, 100vw) - 1180px) * 0.015), 16px); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #fff; color: #000; font: 1.1rem/1.4 'Jost', system-ui, sans-serif;
  letter-spacing: 0.02em; }
h1, h2, button { font-feature-settings: "ss01" 1, "ss02" 1; }
button, input, textarea, select { font: inherit; letter-spacing: inherit; color: inherit; }
:focus-visible { outline: 4px solid #000; outline-offset: 3px; }
.band :focus-visible { outline-color: #000; }

/* ---- header: blue like magpiekids.com; stays put ---- */
.top { position: sticky; top: 0; z-index: 10; background: var(--blue); color: #fff; border-bottom: 3px solid #000; }
.top-inner { max-width: var(--page-max); margin: 0 auto; padding: 12px 16px 0; display: flex; flex-direction: column; gap: 6px; }
.top h1 { margin: 0; font-size: 1.875rem; font-weight: 500; }
/* Page tabs sit on the header's bottom edge; the current one joins the white strip below. */
.tabs { display: flex; gap: 6px; margin-bottom: -3px; position: relative; }
.tabs a { color: #fff; text-decoration: none; background: color-mix(in srgb, var(--blue) 70%, black);
  border: 3px solid #000; border-radius: .5rem .5rem 0 0; padding: 6px 22px 5px; font-weight: 500; }
.tabs a:hover { background: var(--yellow); color: #000; }
.tabs a[aria-current=page] { background: #fff; color: #000; font-weight: 700; border-bottom-color: #fff; padding-bottom: 8px; }

/* On a phone the page must never be wider than the screen (the browser would zoom out to fit it and
   leave blank space at the right): tabs get tighter and the one-line notes may wrap. */
@media (max-width: 520px) {
  .tabs { gap: 4px; }
  .tabs a { padding-left: 10px; padding-right: 10px; }
  .intro .nw { white-space: normal; }
  .setting { flex-wrap: wrap; gap: 6px 12px; }
  .setting select { max-width: 100%; }
}

/* ---- buttons: pills ---- */
button { background: #fff; border: 2px solid #000; border-radius: 100vmax; padding: 6px 20px; cursor: pointer; }
button:not(.part):hover { background: var(--yellow); }
button.primary { background: #000; color: #fff; font-weight: 600; font-size: 1.2rem; padding: 8px 26px; }
button.primary:hover { background: #000; filter: drop-shadow(0 0 8px var(--purple)); }
button.link { background: none; border: none; padding: 0; color: var(--purple-dark);
  text-decoration: underline; font-size: 1rem; margin: 0 0 14px; }
button.link:hover { background: none; text-decoration-thickness: 2px; }
.float { position: fixed; right: 20px; bottom: 20px; z-index: 20; box-shadow: 0 0 0 4px #fff, 0 4px 16px rgba(0, 0, 0, .45); }

.error { max-width: var(--page-max); margin: 12px auto; background: var(--tint-closed); border: 3px solid #000;
  border-radius: .5rem; padding: 8px 14px; }

/* ---- sections: full-width rainbow bands, in the site's order ---- */
.intro { max-width: var(--page-max); margin: 0 auto; padding: 22px 16px 10px; }
.intro p { margin: 0; max-width: 60rem; }
.nw { white-space: nowrap; }
.legend.compact .legend-lead { display: none; }
.key { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; white-space: nowrap; }
.swatch { width: 1.1em; height: 1.1em; border: 2px solid #000; border-radius: 4px; display: inline-block; }
.band { padding: 28px 16px 34px; }
/* A page ending in a .band-fill makes the page at least window-tall, with the fill taking what is left. */
body:has(.band-fill) { display: flex; flex-direction: column; min-height: 100vh; }
body:has(.band-fill) main { flex: 1; display: flex; flex-direction: column; }
main:has(.band-fill) > * { width: 100%; }
.band-fill { flex: 1; min-height: 6rem; padding: 0; }
.band-inner { max-width: var(--page-max); margin: 0 auto; }
.band h2 { margin: 0 0 14px; font-size: 1.875rem; font-weight: 500; line-height: 1.2; }
.band .lede { margin: -6px 0 16px; max-width: 60rem; }
/* Starts on purple and runs backwards through the site's colors. */
.b0 { background: var(--purple); color: #fff; }
.b1 { background: var(--blue); color: #fff; }
.b2 { background: var(--green); color: #000; }
.b3 { background: var(--yellow); color: #000; }
.b4 { background: var(--orange); color: #000; }
.b5 { background: var(--red); color: #fff; }
.loading { text-align: center; padding: 20px; }

/* ---- the week grid and the one card used everywhere ---- */
.week { display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(8.9 * var(--u) + 26px), 1fr));
  /* sideways gap flexes with the window: 16px at the tightest, 20px at the loosest. The white halo
     around each card takes about 4px off each side, so even the tightest leaves 8px of color between cards. */
  column-gap: clamp(16px, calc(var(--vw, 100vw) * 0.014), 20px); row-gap: 18px; padding: 5px;
  /* Card text is 1.1 of the card rem, like the page text. */
  font-size: calc(1.1 * var(--u));
  --halo: 0 0 0 calc(.3125 * var(--u)) #fff;
  /* Height of a date/hours sticker: three lines (weekday 1.2, date and hours 1.1 card rem at line-height
     1.4), two 2px gaps, 10px padding top and bottom and a 3px border each side. The message sticker
     is 2x this. */
  --hours-h: calc(1.4 * (1.2 * var(--u) + 1.1 * var(--u) + 1.1 * var(--u)) + 4px + 20px + 6px); }

/* The card is a white bubble holding two black-bordered stickers: date and hours, then the
   message. Each sticker is its own button. */
.card { display: flex; flex-direction: column; gap: calc(.375 * var(--u)); padding: calc(.375 * var(--u)); background: #fff; color: #000;
  border-radius: calc(.75 * var(--u)); box-shadow: var(--halo); min-width: 0; }
.part { all: unset; box-sizing: border-box; display: flex; flex-direction: column; gap: 2px; padding: 10px;
  background: #fff; color: #000; border: 3px solid #000; border-radius: calc(.5 * var(--u)); cursor: pointer;
  font: inherit; letter-spacing: inherit; min-width: 0; position: relative; }
.part:hover { transform: translateY(-2px); }
.part:focus-visible { outline: 4px solid #000; outline-offset: 3px; }
.part-message { flex: 1; min-height: calc(2 * var(--hours-h)); }
/* Full, bold brand colors; white text where the color is dark enough to need it. */
.tint-closed { background: var(--red); color: #fff; }
.tint-hours { background: var(--orange); color: #000; }
.tint-note { background: var(--blue); color: #fff; }
.part:disabled { background: #d9d9d9; color: #6a6a6a; border-color: #8a8a8a; cursor: default; transform: none; }
.card-name { font-weight: 700; font-size: calc(1.2 * var(--u)); }
.card-date { font-weight: 500; white-space: nowrap; }
/* The repeat badge is a yellow dot. In the hours sticker it sits top right beside the weekday
   (which reserves room for it); in the message sticker it is the last thing, bottom right, in
   normal flow, so it can never cover text: the sticker just grows to make room. */
.repeat-mark { flex: none; width: calc(1.5 * var(--u)); height: calc(1.5 * var(--u)); display: grid; place-items: center; border-radius: 50%;
  background: var(--yellow); color: #000; font-size: var(--u); font-weight: 700; line-height: 1; }
.part-hours .repeat-mark { position: absolute; top: 6px; right: 6px; }
.part-hours:has(.repeat-mark) .card-name { padding-right: calc(1.5 * var(--u)); }
.part-message:has(.repeat-mark) { row-gap: 6px; }
.part:disabled .repeat-mark { background: #a8a8a8; color: #6a6a6a; } /* past days: a mid grey, dark grey glyph (the disabled-text grey); low contrast on purpose */
/* same 6px inset from the corner as in the hours sticker (the part pads 10px) */
.part-message .repeat-mark { margin: auto -4px -4px 0; align-self: flex-end; }
.card-hours { font-weight: 600; font-size: 1em; white-space: nowrap; }
.card-hours.closed { color: var(--red-dark); }
.card-hours.follow, .card-date.wrap { font-weight: 400; white-space: normal; }
.card-hours.follow { font-style: italic; }
.tint-closed .card-hours.closed { color: #fff; }
.part:disabled .card-hours.closed { color: inherit; }
.card-title { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
/* The whole message is shown (the limit is 400 characters): the sticker grows, and so does the week's row. */
.card-msg { line-height: 1.3; overflow-wrap: anywhere; white-space: pre-line; }
.card-qr { display: block; width: min(100%, calc(9 * var(--u))); aspect-ratio: 1; margin: 4px auto 0; background: #fff; border-radius: 4px; }
.card-qr svg { display: block; width: 100%; height: 100%; }
.card-empty { font-style: italic; font-weight: 400; }

/* ---- the editor dialog ---- */
/* The dialog never scrolls on its own: it sits in the page (top set from the scroll position when it
   opens), so the page's one scrollbar handles tall content. */
dialog { position: absolute; left: 0; right: auto; margin: 0; font-size: 17.6px; max-height: none; overflow: visible;
  border: 3px solid #000; border-radius: 12px; background: #fff; color: #000;
  width: min(500px, calc(100vw - 32px)); padding: 24px; box-shadow: 0 0 0 6px #fff, 0 0 40px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
/* The small "are you sure?" box sits in the middle of the window, over the editor. */
#confirm { position: fixed; inset: 0; margin: auto; height: fit-content; width: min(440px, calc(100vw - 32px)); }
#confirm p { margin: 0 0 18px; }
dialog h2 { margin: 0 0 14px; font-size: 25.6px; font-weight: 600; }
/* Tabs on top of the dialog: "Just this day" | "The repeating event" */
.scope { display: flex; gap: 6px; margin: 0 0 -3px; position: relative; z-index: 1; }
.scope button { flex: 1; border-radius: 8px 8px 0 0; border: 3px solid #000; padding: 8px 12px 10px;
  text-align: left; line-height: 1.2; background: #e9e9e9; font-weight: 500; }
.scope button:hover { background: var(--yellow); }
.scope button[aria-selected=true] { background: #fff; border-bottom-color: #fff; font-weight: 700; }
.scope button.repeat-tab.is-off { color: #444; }
.scope button.repeat-tab[aria-selected=true] { background: var(--purple-tint); border-bottom-color: var(--purple-tint); }
.scope .sub { display: block; font-size: 14.4px; font-weight: 400; margin-top: 2px; }
.panel { border: 3px solid #000; border-radius: 0 0 8px 8px; padding: 16px; margin-bottom: 14px; background: #fff; }
.panel.is-repeat { background: var(--purple-tint); }
.panel.solo { border-radius: 8px; }
.panel .banner { margin: 0 0 12px; font-weight: 600; }
.pills { display: inline-flex; border: 2px solid #000; border-radius: 100vmax; overflow: hidden; margin-bottom: 14px; }
.pills input { position: absolute; opacity: 0; pointer-events: none; }
.pills label { padding: 6px 24px; cursor: pointer; font-weight: 500; }
.pills input:checked + label { background: #000; color: #fff; font-weight: 600; }
.pills input:focus-visible + label { outline: 4px solid var(--purple); outline-offset: -4px; }
input[type=date], input[type=time], input[type=text], input[type=number], textarea, select {
  background: #fff; border: 2px solid #000; border-radius: 8px; padding: 6px 10px; }
.times { display: flex; gap: 14px; margin-bottom: 14px; }
.times label { display: flex; flex-direction: column; gap: 2px; font-weight: 500; flex: 1; min-width: 0; }
.times input { width: 100%; min-width: 0; }
/* The gap under a label clears the 4px focus ring of the box below it. */
.field { display: flex; flex-direction: column; gap: 9px; margin-bottom: 20px; }
.field label { font-weight: 500; display: flex; justify-content: space-between; }
.rich { background: #fff; border: 2px solid #000; border-radius: 8px; padding: 6px 10px; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.4em; }
#message.rich { min-height: 5.5em; max-height: 11em; overflow-y: auto; }
.rich:empty::before { content: attr(data-placeholder); color: #666; pointer-events: none; }
.rich:focus { outline: 4px solid var(--purple); outline-offset: 1px; }
.row { display: flex; align-items: center; gap: 10px; }
.row .rich { flex: 1; min-width: 0; }
.fmt { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 16px; margin: 14px 0 0; }
.fmt-label { font-weight: 500; margin: 0 -2px 0 8px; }
/* The link toggle sits at the right end of the row (flush with the box above) and the formatting controls fade out beside it, so it never moves.
   The message box and the link panel share one grid cell (so the height never jumps) and crossfade. */
.fmt-ctls { flex: 1; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; transition: opacity .2s; }
#link-toggle { margin-left: auto; }
.swap { display: grid; grid-template-columns: minmax(0, 1fr); }
.swap > * { grid-area: 1 / 1; min-width: 0; transition: opacity .2s, transform .2s; }
.link-panel { align-self: start; display: flex; flex-direction: column; gap: 12px; opacity: 0; transform: translateY(6px); }
.link-panel label { justify-content: flex-start; align-items: center; gap: 10px; }
.link-panel label span { flex: none; width: 3em; }
/* Lines up with the input boxes (label width, 3em of the dialog's 17.6px text, plus the gap), not the labels. */
.link-note { margin: 4px 0 0 calc(3 * 17.6px + 10px); font-size: 16.5px; line-height: 1.4; color: #444; }
.link-panel input { flex: 1; min-width: 0; }
#message-field[data-mode=link] #message { opacity: 0; transform: translateY(-6px); }
#message-field[data-mode=link] .link-panel { opacity: 1; transform: none; }
#message-field[data-mode=link] .fmt-ctls { opacity: 0; }
#message-field[data-mode=link] #message-count { visibility: hidden; }
#message-field.instant, #message-field.instant * { transition: none !important; }
@media (prefers-reduced-motion: reduce) { .fmt-ctls, .swap > * { transition: none; } }
.fmt button, .picker button { flex: none; width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 50%; font-size: 16px; }
/* A color picker is one round dot that shows the current color and opens a small menu of the others. */
.picker { position: relative; display: inline-flex; }
.picker .dot, .picker .menu button { background: var(--c, #000); }
.picker .dot:hover, .picker .menu button:hover { background: var(--c, #000); filter: brightness(1.08); }
.picker .menu { position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 5; display: flex; gap: 6px; padding: 8px;
  background: #fff; border: 2px solid #000; border-radius: 100vmax; box-shadow: 0 0 0 4px #fff, 0 6px 18px rgba(0, 0, 0, .35); }
.picker[data-picker=bg] .menu { left: auto; right: 0; } /* open upward, toward the dialog */
.picker .menu[hidden] { display: none; }
.picker .menu button[aria-pressed=true] { outline: 3px solid var(--purple); outline-offset: 1px; }
/* Bold and italic show as on by inverting: solid black with a white letter. */
.fmt [data-cmd][aria-pressed=true], .fmt [data-cmd][aria-pressed=true]:hover,
#link-toggle[aria-pressed=true], #link-toggle[aria-pressed=true]:hover { background: #000; color: #fff; }
.count { font-variant-numeric: tabular-nums; font-weight: 400; }
.count.near { color: var(--red-dark); font-weight: 600; }
.count.over { color: #fff; background: var(--red-dark); border-radius: 6px; padding: 0 6px; font-weight: 600; }
.hint { background: var(--tint-hours); border-radius: 8px; padding: 6px 12px; font-size: 16px; margin: 0 0 10px; }
/* Holidays: the on/off switch for a holiday's hours or message, and its name and date rule. */
#holiday-box { margin: 0 0 14px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 0 0 4px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: #000; margin: 0; }
#holiday-box .note { margin: 0 0 12px; font-size: 16px; color: #444; }
#h-details summary { cursor: pointer; font-weight: 500; }
.panel.h-off #hours-fields, .panel.h-off #message-fields, .panel.h-off #lights-fields { opacity: .55; }
details.repeat { margin: 0 0 14px; }
details.repeat summary { cursor: pointer; font-weight: 500; }
details.repeat > select { margin-top: 8px; }
.rule { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; }
.rule label { display: flex; flex-direction: column; gap: 2px; font-weight: 500; }
.rule input[type=number] { width: 5em; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }
/* The dialog is always the full-size design, whatever the page is scaled to. */
dialog button.link { font-size: 16px; }
/* The "use the regular/repeating ..." and "delete this repeating event" control is an ordinary white button. */
#revert { font-size: 16px; display: block; margin: 0 0 14px auto; } /* right-aligned */
dialog button.primary { font-size: 19.2px; }
.band { scroll-margin-top: 84px; }

/* "Weeks start on [day]" */
.setting { display: inline-flex; align-items: center; gap: 12px; font-weight: 500; font-size: 1.2rem; }
.setting select { font-weight: 500; color: #000; padding: 6px 12px; }

.add-holiday { margin-top: 18px; font: inherit; font-weight: 700; padding: 10px 18px; border: 2px solid #000; border-radius: 999px; background: #fff; color: #000; cursor: pointer; }
.add-holiday:hover { background: #f3f3f3; }

/* ---- string lights: a row of bulbs on the card, and the pattern builder in the editor ---- */
:root { --bulb-red: #fc5f60; --bulb-orange: #fdb225; --bulb-yellow: #fddf3c; --bulb-green: #98c76e;
  --bulb-blue: #4a78e0; --bulb-cyan: #5cbbda; --bulb-purple: #996ad5; --bulb-white: #ffffff; }
.part-lights { gap: 6px; }
.part-lights .card-name { font-size: 1em; }
.strip { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.strip .bulbs { display: flex; flex-wrap: wrap; gap: 4px; }
.bulb { width: calc(.9 * var(--u, 16px)); height: calc(.9 * var(--u, 16px)); border-radius: 50%; border: 2px solid #000; background: var(--c, #fff); flex: none; }
.strip .bulb { width: 18px; height: 18px; }
#lights-fields select { display: block; margin-top: 4px; }
.l-buttons { gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.builder { border-top: 2px solid #000; margin-top: 10px; padding-top: 6px; }
.bulb-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.bulb-row .picker .dot { width: 30px; height: 30px; }
.bulb-row .picker .menu { flex-wrap: wrap; max-width: 260px; }
.bulb-row .picker .menu button.remove { background: #fff; color: #000; }
.bulb-row .add, .bulb-row .rm { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 50%; }
.part-lights .strip { margin: 2px 0; }
.part-lights .strip .bulbs { display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; }
.part-lights .strip .bulb { width: auto; height: auto; aspect-ratio: 1; border-width: 1px; }
.part-lights .strip .bulb[data-c=white] { border-color: #b8b8b8; } /* a faint outline: white on a tinted card still needs an edge */
/* Bulbs have no outline, except white ones, which would vanish without it. */
.bulb:not([data-c=white]), .bulb-row .picker button[data-c]:not([data-c=white]) { border-color: transparent; }
