/* Circle — the willperlak.com theme.
 *
 * The house style from WORKSPACE.md, spoken in this app's markup: near-black
 * starfield, Comic Sans, ridged purple frames, a cyan double border, a yellow
 * accent, square corners. There is no shared stylesheet across the apps and
 * there is not meant to be one — what they share is a vocabulary, and
 * static/home/index.html in willperlak.com is its source of truth.
 *
 * Every rule is scoped under [data-theme="retro"] because clean.css is linked
 * at the same time: an unscoped rule would leak onto the other theme the
 * moment somebody switched back. base.css owns layout; this file only sets
 * what base.css deferred — colour, border texture, the font, one animation.
 */

/* Comic Sans MS ships with Windows and macOS but not with iOS, Android or
   most Linux boxes. The stack must not end in the generic script face: on iOS
   Safari that resolves to Snell Roundhand, a formal copperplate, which is the
   wrong joke entirely. Comic Relief is a metrically equivalent libre clone
   (SIL OFL), so it stands in without reflowing a line.

   Self-hosted, never a CDN: the CSP is `default-src 'none'` with `font-src
   'self'`, and a CDN would mean punching a hole in it for every app in the
   workspace. @font-face cannot be scoped to a theme, but only --font-body
   names the family and clean.css never does, so a visitor on Clean never
   downloads the file — and neither does a machine that has the real thing,
   because Comic Relief is listed second.

   Served by the edge (willperlak.com's /fonts/, WORKSPACE.md), not this app:
   there is no public/fonts/ here any more. Locally (a bare `npm start`,
   with no edge in front) these 404 and the stack falls back to the next
   name; the vendored tokens above still load. */
@font-face {
  font-family: "Comic Relief";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/comic-relief-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Comic Relief";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/comic-relief-latin-700-normal.woff2") format("woff2");
}

/* The house colour tokens, radii, font stack and the toast aliases all come
   from css/kit/retro-tokens.css now; only the app-local tokens (bucket-*,
   mark-*, hue-*) still live here, restated per variant as they always were. */
:root[data-theme="retro"] {
  /* Saturated and legible. This theme is a period pastiche, not an excuse for
     the low-contrast grey-on-black that period actually shipped. */
  --bucket-green-bg: #33ff33;
  --bucket-green-fg: #003300;
  --bucket-yellow-bg: #ffee00;
  --bucket-yellow-fg: #3d3300;
  --bucket-orange-bg: #ff9900;
  --bucket-orange-fg: #331400;
  --bucket-red-bg: #b30000;
  --bucket-red-fg: #ffeeee;
  --bucket-none-bg: #2a0033;
  --bucket-none-fg: #e6ccff;

  /* What a day is carrying: a firm plan, somebody's idea, or a clash with
     the viewer's own availability. */
  --mark-event-bg: #00ccff;
  --mark-event-fg: #001018;
  --mark-interest-bg: #ffee00;
  --mark-interest-fg: #332b00;
  --mark-busy-bg: #9a86c8;
  --mark-busy-fg: #0d0018;

  /* Avatar colours, picked by id modulo ten. Bright fills with near-black
     initials: ten hues that stay apart from each other on a dark page. */
  --hue-0-bg: #ff66cc; --hue-0-fg: #2b0018;
  --hue-1-bg: #66ccff; --hue-1-fg: #001a2b;
  --hue-2-bg: #66ff99; --hue-2-fg: #00291a;
  --hue-3-bg: #ffcc66; --hue-3-fg: #2b1a00;
  --hue-4-bg: #cc99ff; --hue-4-fg: #1a0033;
  --hue-5-bg: #ff9966; --hue-5-fg: #2b0d00;
  --hue-6-bg: #66ffe0; --hue-6-fg: #002b26;
  --hue-7-bg: #ffee66; --hue-7-fg: #2b2600;
  --hue-8-bg: #99ff66; --hue-8-fg: #1a2b00;
  --hue-9-bg: #ff8888; --hue-9-fg: #2b0000;
}

/* The starfield, drawn entirely in CSS so the page never fetches an image —
   the two woff2 files are the only thing this theme ever requests. Copied in
   spirit from static/home/index.html, which is the canonical version. */
@keyframes circle-twinkle {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.9; }
}

[data-theme="retro"] body {
  background-color: var(--bg);
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff, transparent),
    radial-gradient(1px 1px at 25% 65%, #fff, transparent),
    radial-gradient(2px 2px at 35% 15%, #fff, transparent),
    radial-gradient(1px 1px at 45% 80%, #fff, transparent),
    radial-gradient(1px 1px at 55% 35%, #fff, transparent),
    radial-gradient(2px 2px at 65% 55%, #fff, transparent),
    radial-gradient(1px 1px at 75% 10%, #fff, transparent),
    radial-gradient(1px 1px at 85% 75%, #fff, transparent),
    radial-gradient(2px 2px at 95% 40%, #fff, transparent),
    radial-gradient(1px 1px at 5% 90%, #fff, transparent),
    radial-gradient(1px 1px at 15% 45%, #fff, transparent),
    radial-gradient(1px 1px at 30% 95%, #fff, transparent),
    radial-gradient(2px 2px at 50% 5%, #fff, transparent),
    radial-gradient(1px 1px at 70% 85%, #fff, transparent),
    radial-gradient(120px 120px at 80% 25%, rgba(200, 120, 255, 0.28), transparent 70%),
    radial-gradient(160px 160px at 15% 70%, rgba(80, 160, 255, 0.24), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
}

/* The twinkle is confined to a decorative layer that sits behind everything
   readable — "restrained" means the animation never touches type. It hangs
   off body rather than off #app, and at z-index -1 rather than 0, because
   raising #app's own children above it means setting `position` on them, and
   that quietly beat the `position: fixed` the bottom tab bar depends on. */
[data-theme="retro"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 60% 12%, #fff, transparent),
    radial-gradient(1px 1px at 88% 62%, #fff, transparent),
    radial-gradient(1px 1px at 42% 88%, #fff, transparent);
  animation: circle-twinkle 6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  [data-theme="retro"] body::after { animation: none; }
}

/* ============================== Controls =================================
 * This comes first on purpose: it is the fallback every <button> in the app
 * lands on, and everything below that carries its own look out-specifies it.
 * Without it the month arrows, "Today", Share and the rest fall through to
 * the browser's own chrome — #eaeaea body text on the UA's #efefef
 * buttonface, which measures 1.04:1 and is simply invisible.
 */
/* :not(:where(.wp-segment)): Kit's appearance-control segments draw their
   own retro look (a filled accent square, no frame); the bare `button`
   selector otherwise outranks .wp-segment's, boxing every segment in a
   purple outset frame Kit's own retro block never drew (review F1).
   :where() keeps the exclusion's specificity at zero: a plain
   `:not(.wp-segment)` ties the class column with any other single-class
   button rule (.cal-day, .rsvp-btn[...], .seg-btn[...]) and then wins
   outright on the extra `button` type selector, silently overriding their
   own colours (caught rendering the calendar wrong after the first draft
   of this fix). */
[data-theme="retro"] button:not(:where(.wp-segment)),
[data-theme="retro"] .button {
  background-color: var(--surface);
  color: var(--accent);
  border: 2px outset var(--border);
  font-family: inherit;
  font-weight: bold;
}

[data-theme="retro"] button:not(:where(.wp-segment)):hover,
[data-theme="retro"] .button:hover {
  background-color: #2a0044;
  color: #66ff66;
}

[data-theme="retro"] button:not(:where(.wp-segment)):active,
[data-theme="retro"] .button:active {
  border-style: inset;
}

[data-theme="retro"] input,
[data-theme="retro"] select,
[data-theme="retro"] textarea {
  background-color: var(--surface-alt);
  color: var(--text);
  border: 2px inset var(--border);
}

[data-theme="retro"] ::placeholder { color: var(--text-muted); opacity: 1; }

[data-theme="retro"] .field-row > label,
[data-theme="retro"] .field-label,
[data-theme="retro"] .facts dt {
  color: var(--focus);
}

[data-theme="retro"] .primary {
  background-color: var(--accent);
  color: var(--accent-text);
  border: 3px outset #66ff66;
}

[data-theme="retro"] .primary:hover {
  background-color: #66ff66;
  color: var(--accent-text);
}

[data-theme="retro"] .danger {
  background-color: var(--danger);
  color: var(--danger-text);
  border: 3px outset #ff99aa;
}

[data-theme="retro"] .danger:hover {
  background-color: #ff6677;
  color: var(--danger-text);
}

[data-theme="retro"] .link-btn {
  background: none;
  border: 0;
  color: var(--link);
  font-weight: normal;
}

[data-theme="retro"] .link-btn:hover { color: var(--focus); }

[data-theme="retro"] .errors {
  background-color: var(--toast-error-bg);
  color: var(--toast-error-fg);
  border: 2px solid var(--danger);
}

[data-theme="retro"] .muted,
[data-theme="retro"] .empty,
[data-theme="retro"] .tbd-hint,
[data-theme="retro"] .option-meta,
[data-theme="retro"] .person-row-sub,
[data-theme="retro"] .comment-time,
[data-theme="retro"] .feed-time,
[data-theme="retro"] .sched-day-empty,
[data-theme="retro"] .sched-time-label,
[data-theme="retro"] .sched-interval-time,
[data-theme="retro"] #demo-note {
  color: var(--text-muted);
}

/* ============================== The chrome =============================== */

/* Ridged purple above, the cyan double rule below: the marquee frame off the
   landing page, standing in for a <marquee> nobody has to endure. */
[data-theme="retro"] #topbar {
  background-color: var(--surface-alt);
  border-top: 3px ridge var(--border);
  border-bottom: 4px double var(--border-alt);
}

[data-theme="retro"] #brand {
  color: var(--accent);
  text-shadow: 2px 2px 0 var(--border), -1px -1px 0 var(--border-alt);
}

[data-theme="retro"] #brand:hover { color: var(--focus); }

[data-theme="retro"] .topbar-link { color: var(--border-alt); }

[data-theme="retro"] .badge {
  background-color: var(--danger);
  color: var(--danger-text);
  border: 1px solid var(--border-alt);
}

[data-theme="retro"] #offline-banner {
  background-color: var(--toast-error-bg);
  color: var(--toast-error-fg);
  border-bottom: 3px ridge var(--border);
  font-weight: bold;
}

[data-theme="retro"] #demo-bar {
  background-color: var(--surface);
  color: var(--text);
  border-bottom: 3px ridge var(--border);
}

/* ================================= Nav =================================== */

[data-theme="retro"] #nav {
  background-color: var(--surface-alt);
  border-right: 3px ridge var(--border);
}

[data-theme="retro"] .nav-link {
  color: var(--accent);
  border: 2px outset var(--border);
  background-color: var(--surface);
  font-weight: bold;
}

[data-theme="retro"] .nav-link:hover {
  background-color: #2a0044;
  color: #66ff66;
}

[data-theme="retro"] .nav-link[aria-current="page"] {
  background-color: var(--border);
  color: var(--bg);
  border-style: inset;
}

/* ============================== Panels =================================== */

/* 3px ridge outside, 4px double cyan inside: the landing page's two frames,
   one drawn as a border and one as an overlay so the padding stays base's. */
[data-theme="retro"] .panel,
[data-theme="retro"] #calendar-pane,
[data-theme="retro"] #ft-calendar-pane {
  position: relative;
  background-color: rgba(0, 0, 20, 0.82);
  border: 3px ridge var(--border);
  padding: 1.15rem 1.25rem;
}

[data-theme="retro"] .panel::before,
[data-theme="retro"] #calendar-pane::before,
[data-theme="retro"] #ft-calendar-pane::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 4px double var(--border-alt);
  pointer-events: none;
}

[data-theme="retro"] .view-title { color: var(--focus); }

[data-theme="retro"] .panel h2,
[data-theme="retro"] .panel h3,
[data-theme="retro"] #import-scheduler summary { color: var(--border-alt); }

[data-theme="retro"] .back-link { color: var(--border-alt); }

/* ============================== Segmented ================================ */

[data-theme="retro"] .segmented,
[data-theme="retro"] .kind-toggle {
  background-color: var(--surface-alt);
  border: 2px inset var(--border);
}

[data-theme="retro"] .seg-btn {
  background-color: var(--surface);
  color: var(--accent);
  border: 2px outset var(--border);
  font-weight: bold;
}

[data-theme="retro"] .seg-btn[aria-selected="true"],
[data-theme="retro"] .seg-btn[aria-pressed="true"],
[data-theme="retro"] .seg-radio:checked + .seg-btn {
  background-color: var(--focus);
  color: var(--surface);
  border-style: inset;
}

[data-theme="retro"] .rsvp-btn[data-response="yes"][aria-pressed="true"] {
  background-color: var(--accent);
  color: var(--accent-text);
}

[data-theme="retro"] .rsvp-btn[data-response="maybe"][aria-pressed="true"] {
  background-color: var(--bucket-yellow-bg);
  color: var(--bucket-yellow-fg);
}

[data-theme="retro"] .rsvp-btn[data-response="no"][aria-pressed="true"] {
  background-color: var(--danger);
  color: var(--danger-text);
}

/* ============================ Cards and rows ============================= */

[data-theme="retro"] .event-card,
[data-theme="retro"] .person-row,
[data-theme="retro"] .option-row,
[data-theme="retro"] .comment,
[data-theme="retro"] .feed-item,
[data-theme="retro"] .check-item,
[data-theme="retro"] .check-row,
[data-theme="retro"] .sched-day {
  background-color: var(--surface);
  border: 2px solid var(--border-alt);
  color: var(--text);
}

[data-theme="retro"] .event-card-link,
[data-theme="retro"] .person-row-link,
[data-theme="retro"] .feed-link {
  color: var(--text);
}

[data-theme="retro"] .event-card-title { color: var(--accent); }

[data-theme="retro"] .event-card[data-kind="interest"] {
  border-color: var(--focus);
  border-style: dashed;
}

[data-theme="retro"] .event-card[data-status="cancelled"] {
  border-color: var(--danger);
}

[data-theme="retro"] .event-card[data-status="cancelled"] .event-card-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

[data-theme="retro"] .feed-item-unread {
  border-color: var(--focus);
  background-color: #24003a;
}

[data-theme="retro"] .person-row[data-state="free"] { border-color: var(--accent); }
[data-theme="retro"] .person-row[data-state="busy"] { border-color: var(--danger); }

[data-theme="retro"] .person-chip {
  background-color: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
}

[data-theme="retro"] .person-chip[data-response="yes"] { border-color: var(--accent); }
[data-theme="retro"] .person-chip[data-response="maybe"] { border-color: var(--focus); }
[data-theme="retro"] .person-chip[data-response="no"] { border-color: var(--danger); }

/* ================================ Badges ================================= */

[data-theme="retro"] .badge-kind[data-kind="event"] {
  background-color: var(--mark-event-bg);
  color: var(--mark-event-fg);
}

[data-theme="retro"] .badge-kind[data-kind="interest"] {
  background-color: var(--mark-interest-bg);
  color: var(--mark-interest-fg);
}

[data-theme="retro"] .badge-status[data-status="active"] {
  background-color: var(--accent);
  color: var(--accent-text);
}

[data-theme="retro"] .badge-status[data-status="cancelled"] {
  background-color: var(--danger);
  color: var(--danger-text);
}

[data-theme="retro"] .badge-conflict {
  background-color: var(--mark-busy-bg);
  color: var(--mark-busy-fg);
}

[data-theme="retro"] .badge-full {
  background-color: var(--bucket-orange-bg);
  color: var(--bucket-orange-fg);
}

/* ================================ Avatars ================================ */

/* Square, not round: there is no border radius anywhere in this theme. */
[data-theme="retro"] .avatar {
  border-radius: 0;
  border: 2px outset var(--border);
}

[data-theme="retro"] .avatar[data-hue="0"] { background-color: var(--hue-0-bg); color: var(--hue-0-fg); }
[data-theme="retro"] .avatar[data-hue="1"] { background-color: var(--hue-1-bg); color: var(--hue-1-fg); }
[data-theme="retro"] .avatar[data-hue="2"] { background-color: var(--hue-2-bg); color: var(--hue-2-fg); }
[data-theme="retro"] .avatar[data-hue="3"] { background-color: var(--hue-3-bg); color: var(--hue-3-fg); }
[data-theme="retro"] .avatar[data-hue="4"] { background-color: var(--hue-4-bg); color: var(--hue-4-fg); }
[data-theme="retro"] .avatar[data-hue="5"] { background-color: var(--hue-5-bg); color: var(--hue-5-fg); }
[data-theme="retro"] .avatar[data-hue="6"] { background-color: var(--hue-6-bg); color: var(--hue-6-fg); }
[data-theme="retro"] .avatar[data-hue="7"] { background-color: var(--hue-7-bg); color: var(--hue-7-fg); }
[data-theme="retro"] .avatar[data-hue="8"] { background-color: var(--hue-8-bg); color: var(--hue-8-fg); }
[data-theme="retro"] .avatar[data-hue="9"] { background-color: var(--hue-9-bg); color: var(--hue-9-fg); }

/* ================================ Calendar =============================== */

[data-theme="retro"] .cal-weekday { color: var(--border-alt); }

[data-theme="retro"] .cal-day {
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-alt);
  font-weight: bold;
}

[data-theme="retro"] .cal-day[data-bucket="green"] { background-color: var(--bucket-green-bg); color: var(--bucket-green-fg); }
[data-theme="retro"] .cal-day[data-bucket="yellow"] { background-color: var(--bucket-yellow-bg); color: var(--bucket-yellow-fg); }
[data-theme="retro"] .cal-day[data-bucket="orange"] { background-color: var(--bucket-orange-bg); color: var(--bucket-orange-fg); }
[data-theme="retro"] .cal-day[data-bucket="red"] { background-color: var(--bucket-red-bg); color: var(--bucket-red-fg); }
[data-theme="retro"] .cal-day[data-bucket="none"] { background-color: var(--bucket-none-bg); color: var(--bucket-none-fg); }

/* A day the viewer has no free run in. Hatched rather than greyed out: the
   text colour is left alone so the date stays as readable as any other. */
[data-theme="retro"] .cal-day[data-busy="true"] {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(234, 234, 234, 0.22) 0 3px,
    rgba(0, 0, 0, 0) 3px 7px
  );
}

[data-theme="retro"] .cal-busy { color: var(--mark-busy-bg); }

[data-theme="retro"] .cal-outside { opacity: 0.55; }

[data-theme="retro"] .cal-today {
  border: 2px solid var(--focus);
}

/* The day you tapped is filled solid, so it cannot be confused with the
   thin ring that marks today. */
[data-theme="retro"] .cal-selected {
  background-color: var(--focus);
  color: var(--surface);
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}
[data-theme="retro"] .cal-selected .cal-day-count { color: var(--surface); }

[data-theme="retro"] .option-vote[aria-pressed="true"] {
  background-color: var(--focus);
  color: var(--surface);
  border-style: inset;
}

[data-theme="retro"] .cal-mark { border-radius: 0; }
[data-theme="retro"] .cal-mark[data-mark="event"] { background-color: var(--mark-event-bg); }
[data-theme="retro"] .cal-mark[data-mark="interest"] { background-color: var(--mark-interest-bg); }
[data-theme="retro"] .cal-mark[data-mark="busy"] { background-color: var(--mark-busy-bg); }

[data-theme="retro"] .legend-item { color: var(--text); }
[data-theme="retro"] .legend-item[data-mark="event"] { --swatch: var(--mark-event-bg); }
[data-theme="retro"] .legend-item[data-mark="interest"] { --swatch: var(--mark-interest-bg); }
[data-theme="retro"] .legend-item[data-mark="busy"] { --swatch: var(--mark-busy-bg); }
[data-theme="retro"] .legend-item[data-bucket="green"] { --swatch: var(--bucket-green-bg); }
[data-theme="retro"] .legend-item[data-bucket="yellow"] { --swatch: var(--bucket-yellow-bg); }
[data-theme="retro"] .legend-item[data-bucket="orange"] { --swatch: var(--bucket-orange-bg); }
[data-theme="retro"] .legend-item[data-bucket="red"] { --swatch: var(--bucket-red-bg); }
[data-theme="retro"] .legend-item[data-bucket="none"] { --swatch: var(--bucket-none-bg); }

/* =========================== Schedule editor ============================= */

[data-theme="retro"] .sched-day-name,
[data-theme="retro"] .sched-day-label { color: var(--focus); }

[data-theme="retro"] .sched-interval {
  background-color: #001a00;
  color: var(--accent);
  border: 1px solid var(--accent);
}

[data-theme="retro"] .sched-interval .sched-time-label,
[data-theme="retro"] .sched-interval .sched-interval-time { color: var(--accent); }

/* ================================= Toast ================================= */

[data-theme="retro"] .toast {
  border: 3px outset var(--border);
}

[data-theme="retro"] .toast-info { background-color: var(--toast-info-bg); color: var(--toast-info-fg); }
[data-theme="retro"] .toast-success { background-color: var(--toast-success-bg); color: var(--toast-success-fg); }
[data-theme="retro"] .toast-error { background-color: var(--toast-error-bg); color: var(--toast-error-fg); }

/* ============================ Compact widths ============================= */

@media (max-width: 700px) {
  [data-theme="retro"] #nav {
    border-right: 0;
    border-top: 4px double var(--border-alt);
    background-color: var(--surface-alt);
  }
  [data-theme="retro"] .nav-link {
    border: 0;
    background: none;
  }
  [data-theme="retro"] .nav-link[aria-current="page"] {
    background-color: var(--border);
    color: var(--bg);
  }
}

[data-theme="retro"] .badge-status[data-status="full"] {
  background-color: var(--focus);
  color: var(--surface);
}
[data-theme="retro"] .rsvp-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
