/*
  Wicked Curious base styles: reset, type, layout and shared components.
  Load order in templates/base.html: fonts.css, tokens.css, base.css, then any page CSS.
  CSP note: style="" attributes are blocked in production. Put styles here
  (or in a page stylesheet), never inline. SVG presentation attributes
  (fill, stroke) are fine.
*/

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
img, svg, video { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Page ---------- */
body {
  min-height: 100vh;
  background-color: var(--wc-bg);
  color: var(--wc-text);
  font-family: var(--wc-font-body);
  font-size: var(--wc-size-body);
  line-height: var(--wc-leading-body);
}

.bg-grid {
  background-image:
    linear-gradient(var(--wc-hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--wc-hairline) 1px, transparent 1px);
  background-size: var(--wc-grid-size) var(--wc-grid-size);
}

.container {
  width: min(100% - 2 * var(--wc-space-6), var(--wc-content-max));
  margin-inline: auto;
}

.reading { max-width: var(--wc-reading-max); }

/* ---------- Type ---------- */
h1, h2, h3, .display {
  font-family: var(--wc-font-display);
  font-weight: 800;
  line-height: var(--wc-leading-tight);
  letter-spacing: var(--wc-tracking-headline);
  text-wrap: balance;
}
.display { font-size: clamp(2.75rem, 6vw, var(--wc-size-display)); line-height: 0.95; }
h1 { font-size: clamp(2.25rem, 5vw, var(--wc-size-h1)); }
h2 { font-size: var(--wc-size-h2); }
h3 { font-size: var(--wc-size-h3); font-weight: 700; letter-spacing: -0.02em; }
p { text-wrap: pretty; }

.lede { font-size: 1.25rem; color: var(--wc-text-muted); }
.small { font-size: var(--wc-size-small); line-height: var(--wc-leading-small); }
.muted { color: var(--wc-text-muted); }

.label {
  font-family: var(--wc-font-label);
  font-size: var(--wc-size-label);
  font-weight: 700;
  letter-spacing: var(--wc-tracking-label);
  text-transform: uppercase;
}

.mono { font-family: var(--wc-font-label); }

a { color: var(--wc-link); text-underline-offset: 0.15em; }
a:hover { color: var(--wc-link-hover); }

/* ---------- Focus and accessibility ---------- */
:focus-visible {
  outline: var(--wc-focus-ring);
  outline-offset: var(--wc-focus-offset);
}
.on-dark :focus-visible { outline-color: var(--wc-lantern); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--wc-space-4);
  top: -100px;
  z-index: 100;
  padding: var(--wc-space-2) var(--wc-space-4);
  background: var(--wc-lantern);
  color: var(--wc-spy-pond);
  border: var(--wc-border-width) solid var(--wc-spy-pond);
  border-radius: var(--wc-radius-pill);
  font-weight: 700;
}
.skip-link:focus { top: var(--wc-space-4); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Wordmark (templates/partials/wordmark.html) ---------- */
.wordmark {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  font-family: var(--wc-font-display);
  font-weight: 800;
  line-height: 1;
  color: var(--wc-text);
  text-decoration: none;
  font-size: 30px; /* sets the size of "curio.us"; everything else scales from it */
}
.wordmark:hover { color: var(--wc-text); }
.wordmark__wicked {
  display: inline-block;
  font-size: 0.43em;
  letter-spacing: -0.01em;
  color: var(--wc-bunsen-deep);
  transform: rotate(-6deg);
  transform-origin: left bottom;
  margin: 0 0 -0.08em 0.155em; /* relative to its own (smaller) size */
}
.wordmark__curious {
  display: inline-block;
  letter-spacing: -0.035em;
  white-space: nowrap;
}
.wordmark__eye {
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  overflow: visible;
  margin: 0 0.01em 0 0.015em;
}
.wordmark__eye .ink { stroke: currentColor; fill: none; }
.wordmark__eye .pupil { fill: currentColor; }
.wordmark__eye .glint { fill: var(--wc-bg); }
.wordmark__dot {
  display: inline-block;
  width: 0.16em;
  height: 0.16em;
  border-radius: 50%;
  background: var(--wc-bunsen);
  margin: 0 0.03em 0 0.04em;
}
.on-dark .wordmark, .on-dark .wordmark:hover { color: var(--wc-graph-paper); }
.on-dark .wordmark__wicked { color: var(--wc-bunsen); }
.on-dark .wordmark__eye .glint { fill: var(--wc-spy-pond); }
@media (prefers-color-scheme: dark) {
  .wordmark__wicked { color: var(--wc-bunsen); }
}

/* ---------- Site header and footer ---------- */
.site-header {
  background: var(--wc-spy-pond);
  color: var(--wc-graph-paper);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wc-space-6);
  min-height: 76px;
}
.site-nav { display: flex; align-items: center; gap: var(--wc-space-6); }
.site-nav a {
  color: var(--wc-graph-paper);
  font-weight: 700;
  font-size: var(--wc-size-small);
  text-decoration: none;
  padding-block: var(--wc-space-2);
}
.site-nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--wc-bunsen); }
.site-nav a:hover { color: var(--wc-lantern); }
.site-nav a.btn { color: var(--wc-spy-pond); padding-inline: var(--wc-space-6); }
.site-nav a.btn--secondary { color: var(--wc-graph-paper); }

.site-nav__hello { color: var(--wc-mist); }
.site-menu__panel .site-nav__hello { padding-block: var(--wc-space-2); }

/* Minimal header for sign-up, sign-in and onboarding */
.auth-header { padding-block: var(--wc-space-4); }
.auth-header__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--wc-space-4); }

/* Phone menu: a <details> element, so it works without JavaScript */
.site-menu { display: none; position: relative; }
.site-menu summary {
  display: grid;
  place-items: center;
  width: var(--wc-touch-min);
  height: var(--wc-touch-min);
  border: var(--wc-border-width) solid var(--wc-graph-paper);
  border-radius: var(--wc-radius-pill);
  list-style: none;
  cursor: pointer;
}
.site-menu summary::-webkit-details-marker { display: none; }
.site-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--wc-space-2));
  z-index: 20;
  display: grid;
  gap: var(--wc-space-2);
  min-width: 15rem;
  padding: var(--wc-space-4);
  background: var(--wc-spy-pond);
  border: var(--wc-border-width) solid var(--wc-graph-paper);
  border-radius: var(--wc-radius-card);
}
.site-menu__panel a { color: var(--wc-graph-paper); font-weight: 700; padding-block: var(--wc-space-2); }
.site-menu__panel a.btn { color: var(--wc-spy-pond); }
.site-menu__panel a.btn--secondary { color: var(--wc-graph-paper); }
@media (max-width: 52rem) {
  .site-nav { display: none; }
  .site-menu { display: block; }
}

.site-footer {
  border-top: var(--wc-border-width) solid var(--wc-hairline);
  padding-block: var(--wc-space-8);
  font-size: var(--wc-size-small);
  color: var(--wc-text-muted);
}
.site-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--wc-space-4); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--wc-space-4); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wc-space-2);
  min-height: var(--wc-control-height);
  padding: 0 var(--wc-space-6);
  border: var(--wc-border-width) solid var(--wc-spy-pond);
  border-radius: var(--wc-radius-pill);
  background: var(--wc-white);
  color: var(--wc-spy-pond);
  font-family: var(--wc-font-body);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { color: var(--wc-spy-pond); background: var(--wc-graph-paper); }
.btn--primary { background: var(--wc-bunsen); }
.btn--primary:hover { background: #FF7F47; }
.btn--dark { background: var(--wc-spy-pond); color: var(--wc-graph-paper); }
.btn--dark:hover { background: var(--wc-pond-panel); color: var(--wc-graph-paper); }
.on-dark .btn--secondary { background: transparent; color: var(--wc-graph-paper); border-color: var(--wc-graph-paper); }
.btn--block { width: 100%; }
.btn--lg { min-height: 52px; font-size: 1.0625rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn--danger { background: var(--wc-bunsen-deep); color: var(--wc-white); border-color: var(--wc-bunsen-deep); }
.btn--danger:hover { background: #9A3412; color: var(--wc-white); }
/* A <button> that looks like a link (form actions such as "Save and finish later") */
.link-button { padding: 0; border: 0; background: none; color: var(--wc-link); text-decoration: underline; text-underline-offset: 0.15em; font: inherit; cursor: pointer; min-height: var(--wc-touch-min); }
.link-button:hover { color: var(--wc-link-hover); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--wc-space-1);
  padding: 2px 10px;
  border: var(--wc-border-width) solid var(--wc-spy-pond);
  border-radius: var(--wc-radius-pill);
  background: var(--wc-white);
  color: var(--wc-spy-pond);
  font-family: var(--wc-font-label);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: var(--wc-tracking-label);
  text-transform: uppercase;
  line-height: 1.5;
  white-space: nowrap;
}
.chip--new { background: var(--wc-lantern); }
.chip--science { background: var(--wc-topic-science-bg); color: var(--wc-topic-science-fg); border-color: var(--wc-topic-science-bg); }
.chip--technology { background: var(--wc-topic-technology-bg); color: var(--wc-topic-technology-fg); border-color: var(--wc-topic-technology-bg); }
.chip--engineering { background: var(--wc-topic-engineering-bg); color: var(--wc-topic-engineering-fg); border-color: var(--wc-topic-engineering-bg); }
.chip--arts { background: var(--wc-topic-arts-bg); color: var(--wc-topic-arts-fg); border-color: var(--wc-topic-arts-bg); }
.chip--math { background: var(--wc-topic-math-bg); color: var(--wc-topic-math-fg); }
.chip--nature { background: var(--wc-topic-nature-bg); color: var(--wc-topic-nature-fg); border-color: var(--wc-topic-nature-bg); }
.chip--history { background: var(--wc-topic-history-bg); color: var(--wc-topic-history-fg); border-color: var(--wc-topic-history-bg); }
.chip--reading { background: var(--wc-topic-reading-bg); color: var(--wc-topic-reading-fg); border-color: var(--wc-topic-reading-bg); }

/* Toggle chip: a <button aria-pressed> used for quick filters and onboarding choices */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--wc-space-2);
  min-height: var(--wc-touch-min);
  padding: 0 var(--wc-space-4);
  border: var(--wc-border-width) solid var(--wc-spy-pond);
  border-radius: var(--wc-radius-pill);
  background: var(--wc-white);
  color: var(--wc-spy-pond);
  font-weight: 700;
  font-size: 1rem;
}
.toggle[aria-pressed="true"] { background: var(--wc-spy-pond); color: var(--wc-graph-paper); }
.toggle--lantern[aria-pressed="true"] { background: var(--wc-lantern); color: var(--wc-spy-pond); }

.chip-row { display: flex; flex-wrap: wrap; gap: var(--wc-space-2); }

/* ---------- Pick pills (events filters, onboarding, My feed) ---------- */
/* A real checkbox or radio, drawn as a pill (keyboard and screen readers see the input). */
.picks { display: flex; flex-wrap: wrap; gap: var(--wc-space-2); }
.pick { position: relative; display: inline-flex; }
.pick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.pick > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 var(--wc-space-4);
  border: var(--wc-border-width) solid var(--wc-border);
  border-radius: var(--wc-radius-pill);
  background: var(--wc-surface);
  color: var(--wc-text);
  font-size: 0.95rem;
}
.pick input:checked + span { background: var(--wc-text); color: var(--wc-bg); border-color: var(--wc-text); }
.pick input:focus-visible + span { outline: var(--wc-focus-ring); outline-offset: var(--wc-focus-offset); }
.pick input:hover + span { box-shadow: 0 0 0 1px var(--wc-border); }
.pick--square > span { min-width: 2.75rem; padding: 0 var(--wc-space-2); border-radius: var(--wc-radius-input); font-family: var(--wc-font-label); font-weight: 700; font-size: 0.85rem; }
.picks--days { gap: 6px; }
.segmented { display: flex; border: var(--wc-border-width) solid var(--wc-border); border-radius: var(--wc-radius-input); overflow: hidden; }
.pick--segment { flex: 1; }
.pick--segment > span { width: 100%; border: 0; border-radius: 0; font-family: var(--wc-font-label); }

/* ---------- Cards and panels ---------- */
.card {
  background: var(--wc-surface);
  border: var(--wc-border-width) solid var(--wc-border);
  border-radius: var(--wc-radius-card);
  padding: 20px 22px;
}
.panel-dark {
  background: var(--wc-spy-pond);
  color: var(--wc-graph-paper);
  border-radius: var(--wc-radius-panel);
  padding: var(--wc-space-6);
}
.panel-dark .muted { color: var(--wc-mist); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--wc-space-1); }
.field label, .field legend { font-weight: 700; }
.field__hint { font-size: var(--wc-size-small); color: var(--wc-text-muted); }
.field__error { font-size: var(--wc-size-small); color: var(--wc-bunsen-deep); font-weight: 700; }

.input, .select {
  min-height: var(--wc-control-height);
  width: 100%;
  padding: 0 var(--wc-space-4);
  border: var(--wc-border-width) solid var(--wc-spy-pond);
  border-radius: var(--wc-radius-input);
  background: var(--wc-white);
  color: var(--wc-spy-pond);
}
.input::placeholder { color: var(--wc-slate); opacity: 1; }
.input[aria-invalid="true"] { border-color: var(--wc-bunsen-deep); }

.checkbox { display: flex; align-items: center; gap: var(--wc-space-3); min-height: var(--wc-touch-min); }
.checkbox input { width: 20px; height: 20px; accent-color: var(--wc-spy-pond); }

/* ---------- Notices and messages ---------- */
.notice {
  display: flex;
  gap: var(--wc-space-3);
  align-items: flex-start;
  padding: var(--wc-space-3) var(--wc-space-4);
  background: var(--wc-notice);
  color: var(--wc-spy-pond);
  border: var(--wc-border-width) solid var(--wc-spy-pond);
  border-radius: var(--wc-radius-input);
  font-size: var(--wc-size-small);
}
.notice svg { flex-shrink: 0; }

.messages { display: grid; gap: var(--wc-space-2); margin-block: var(--wc-space-4); }

/* ---------- Event list ---------- */
.day-heading {
  display: flex;
  align-items: baseline;
  gap: var(--wc-space-3);
  margin-block: var(--wc-space-8) var(--wc-space-3);
}
.event-card {
  display: grid;
  grid-template-columns: 6.5rem 1fr auto;
  gap: var(--wc-space-4);
}
.event-card__time { font-family: var(--wc-font-label); font-weight: 700; }
.event-card__title { font-family: var(--wc-font-display); font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.event-card.is-cancelled .event-card__title,
.event-card.is-cancelled .event-card__time { text-decoration: line-through; }
.event-card__meta { display: flex; flex-wrap: wrap; gap: var(--wc-space-4); font-size: var(--wc-size-small); color: var(--wc-text-muted); }
@media (max-width: 40rem) {
  .event-card { grid-template-columns: 1fr; }
}

/* ---------- htmx ---------- */
.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
[aria-busy="true"] { cursor: progress; }

/* ---------- Stamps (town postmarks) ---------- */
.postmark {
  display: inline-grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border: 2px dashed currentColor;
  border-radius: 50%;
  transform: rotate(-8deg);
  font-family: var(--wc-font-label);
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* ---------- Print (passport, single event) ---------- */
@media print {
  .site-header, .site-footer, .skip-link, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .bg-grid { background: none; }
  a { color: inherit; }
}

/* ---------- Error pages ---------- */
.error-page { display: grid; justify-items: center; gap: var(--wc-space-6); padding-block: var(--wc-space-12) var(--wc-space-16); text-align: center; }
.error-code { font-family: var(--wc-font-display); font-weight: 800; font-size: clamp(140px, 20vw, 240px); line-height: 1; letter-spacing: -0.04em; white-space: nowrap; }
.error-code svg { display: inline-block; width: 0.66em; height: 0.66em; overflow: visible; margin: 0 0.02em; }
.error-page .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--wc-space-3); }
