/* tohode — everything arcticss leaves to the application, plus the design system.
   arcticss supplies layout and spacing utilities; this supplies the type scale,
   the palette, interaction states, and the components with real behaviour. */

:root {
  /* --- type scale -------------------------------------------------------
     Five sizes, no more. Every piece of text in the app is one of these.
     Fluid between a phone and a laptop so nothing needs a breakpoint. */
  --t-fine:  0.75rem;                              /* meta, captions, counts */
  --t-small: 0.8125rem;                            /* buttons, chips, labels */
  --t-body:  clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --t-h2:    clamp(1.0625rem, 1rem + 0.5vw, 1.25rem);
  --t-h1:    clamp(1.5rem, 1.15rem + 1.6vw, 2.125rem);

  --lh-tight: 1.2;
  --lh-body:  1.55;

  /* --- palette ----------------------------------------------------------
     Green is getting out of the house. Yellow is the good kind of loud.
     Both are web-safe hex, so they render identically everywhere. */
  --green:        #009966;
  --green-deep:   #00704a;
  --green-wash:   #e6f5ee;
  --yellow:       #ffcc00;
  --yellow-deep:  #8a6a00;
  --yellow-wash:  #fff8e0;

  --ink:        #16191c;
  --ink-soft:   #4a5158;
  --ink-faint:  #767d85;
  --line:       #e4e7ea;
  --line-soft:  #f0f2f4;
  --paper:      #ffffff;
  --page:       #f6f7f8;
  --link:       #0a5fd6;

  --radius:   0.5rem;
  --radius-s: 0.375rem;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgb(22 25 28 / 6%);
  --shadow-lift: 0 2px 4px rgb(22 25 28 / 8%), 0 10px 22px rgb(22 25 28 / 9%);

  /* --- categories -------------------------------------------------------
     One hue each, expanded to a fill, an ink and an edge. Generated from the
     same table the classifier uses, so a new category cannot be added to the
     taxonomy without getting a colour. */
  --cat-music: hsl(268 62% 42%);
  --cat-music-ink: hsl(268 68% 27%);
  --cat-music-bg: hsl(268 70% 95%);
  --cat-music-edge: hsl(268 48% 84%);
  --cat-nightlife: hsl(320 62% 42%);
  --cat-nightlife-ink: hsl(320 68% 27%);
  --cat-nightlife-bg: hsl(320 70% 95%);
  --cat-nightlife-edge: hsl(320 48% 84%);
  --cat-stage: hsl(8 62% 42%);
  --cat-stage-ink: hsl(8 68% 27%);
  --cat-stage-bg: hsl(8 70% 95%);
  --cat-stage-edge: hsl(8 48% 84%);
  --cat-arts: hsl(28 62% 42%);
  --cat-arts-ink: hsl(28 68% 27%);
  --cat-arts-bg: hsl(28 70% 95%);
  --cat-arts-edge: hsl(28 48% 84%);
  --cat-food: hsl(42 62% 42%);
  --cat-food-ink: hsl(42 68% 27%);
  --cat-food-bg: hsl(42 70% 95%);
  --cat-food-edge: hsl(42 48% 84%);
  --cat-outdoors: hsl(140 62% 42%);
  --cat-outdoors-ink: hsl(140 68% 27%);
  --cat-outdoors-bg: hsl(140 70% 95%);
  --cat-outdoors-edge: hsl(140 48% 84%);
  --cat-sports: hsl(178 62% 42%);
  --cat-sports-ink: hsl(178 68% 27%);
  --cat-sports-bg: hsl(178 70% 95%);
  --cat-sports-edge: hsl(178 48% 84%);
  --cat-tech: hsl(212 62% 42%);
  --cat-tech-ink: hsl(212 68% 27%);
  --cat-tech-bg: hsl(212 70% 95%);
  --cat-tech-edge: hsl(212 48% 84%);
  --cat-learning: hsl(250 62% 42%);
  --cat-learning-ink: hsl(250 68% 27%);
  --cat-learning-bg: hsl(250 70% 95%);
  --cat-learning-edge: hsl(250 48% 84%);
  --cat-community: hsl(48 62% 42%);
  --cat-community-ink: hsl(48 68% 27%);
  --cat-community-bg: hsl(48 70% 95%);
  --cat-community-edge: hsl(48 48% 84%);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-size: var(--t-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--page);
  /* The single most common cause of a janky phone layout. */
  overflow-x: hidden;
}

/* Text is left-aligned. Only genuinely centred things — the nav, buttons,
   single-control rows — get centred, and they ask for it explicitly. */
h1, h2, h3, p, dd, dt, li, label, figcaption { text-align: left; }

h1 { font-size: var(--t-h1); line-height: var(--lh-tight); letter-spacing: -0.02em; }
h2 { font-size: var(--t-h2); line-height: var(--lh-tight); letter-spacing: -0.01em; }
h3 { font-size: var(--t-h2); line-height: var(--lh-tight); }

.t-fine  { font-size: var(--t-fine); }
.t-small { font-size: var(--t-small); }
.t-body  { font-size: var(--t-body); }

.soft  { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }

a { color: var(--link); }
a:hover { color: #073f8f; }

.wrap {
  width: 100%;
  max-width: 70rem;
  margin-inline: auto;
  padding-inline: clamp(0.875rem, 3vw, 1.5rem);
}

/* --------------------------------------------------------------- header -- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 500;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.brand-mark {
  width: 1.125rem; height: 1.125rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green) 45%, var(--yellow) 45%);
  box-shadow: 0 0 0 0.2rem rgb(0 153 102 / 12%);
  flex: 0 0 auto;
}

/* The nav scrolls rather than wraps, so the header never doubles in height. */
.nav {
  display: flex;
  gap: 0.125rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav::-webkit-scrollbar { display: none; }

.navlink {
  font-size: var(--t-small);
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-s);
  white-space: nowrap;
}
.navlink:hover { background: var(--line-soft); color: var(--ink); }
.navlink.is-current { background: var(--green); color: #fff; }

/* ------------------------------------------------------------- controls -- */

.btn, .btn-quiet, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font: inherit;
  font-size: var(--t-small);
  font-weight: 650;
  line-height: 1.1;
  /* 44px tall at default size: a real touch target. */
  min-height: 2.75rem;
  padding: 0.5rem 0.9375rem;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  cursor: pointer;
  text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

.btn { background: var(--green); color: #fff; }
.btn:hover { background: var(--green-deep); color: #fff; }

.btn-quiet { background: var(--paper); color: var(--ink); border-color: #d3d8dd; }
.btn-quiet:hover { background: var(--line-soft); }
.btn-quiet[aria-pressed=true] {
  background: var(--green); border-color: var(--green); color: #fff;
}

.btn-danger { background: var(--paper); color: #c11; border-color: #f2cfcf; }
.btn-danger:hover { background: #fdeaea; }

.btn:disabled, .btn-quiet:disabled { opacity: .5; cursor: not-allowed; }

.input, select.input, textarea.input {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.6875rem;
  font: inherit;
  font-size: var(--t-body);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #d3d8dd;
  border-radius: var(--radius-s);
}
.input::placeholder { color: var(--ink-faint); }
textarea.input { min-height: 6rem; resize: vertical; line-height: var(--lh-body); }

:where(.input, .btn, .btn-quiet, .btn-danger, .navlink, .chip, a, summary):focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }

.field-label {
  display: block;
  font-size: var(--t-small);
  font-weight: 650;
  margin-bottom: 0.25rem;
}
.field-hint { font-size: var(--t-fine); color: var(--ink-faint); margin: 0.25rem 0 0; }

/* ----------------------------------------------------------------- chips -- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.6875rem;
  border-radius: var(--radius-pill);
  border: 1px solid #d3d8dd;
  background: var(--paper);
  font-size: var(--t-small);
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { background: var(--line-soft); color: var(--ink); }
.chip.is-active {
  background: var(--ink); border-color: var(--ink); color: #fff;
}
.chip .cat-icon { flex: 0 0 auto; }

/* A category chip wears its own colour once it is on. */
.chip-cat.is-active {
  background: var(--cat-bg);
  border-color: var(--cat-edge);
  color: var(--cat-ink);
}
.chip-cat .cat-icon { color: var(--cat); }
.chip-cat.is-active .cat-icon { color: var(--cat-ink); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* A horizontally scrolling row on phones, wrapping on wider screens. */
.chip-scroller {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0.125rem;
  -webkit-overflow-scrolling: touch;
}
.chip-scroller::-webkit-scrollbar { display: none; }
@media (min-width: 48em) {
  .chip-scroller { flex-wrap: wrap; overflow: visible; }
}

/* ----------------------------------------------------------------- cards -- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr));
  gap: 0.875rem;
}

.event-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: box-shadow .14s ease, transform .14s ease, border-color .14s ease;
}
.event-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.event-card:focus-within { border-color: var(--link); }

.event-card > a {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.card-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--line-soft);
  overflow: hidden;
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* When there is no photograph, the category draws its own cover rather than
   leaving a grey rectangle or borrowing a stock photo of the wrong thing. */
.card-art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 120% at 18% 12%, color-mix(in srgb, var(--cat) 26%, white) 0%, transparent 60%),
    linear-gradient(135deg, var(--cat-bg) 0%, color-mix(in srgb, var(--cat) 14%, white) 100%);
}
.card-art .cat-icon { color: var(--cat); opacity: .62; }
.card-art::after {
  content: ;
  position: absolute; inset: 0;
  background-image: radial-gradient(currentColor 1px, transparent 1px);
  background-size: 14px 14px;
  color: var(--cat);
  opacity: .08;
}

.card-body { padding: 0.8125rem 0.875rem 0.9375rem; display: flex; flex-direction: column; gap: 0.375rem; flex: 1 1 auto; }

.card-when {
  font-size: var(--t-fine);
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--green-deep);
  white-space: nowrap;
}

.card-title {
  font-size: var(--t-h2);
  font-weight: 650;
  line-height: var(--lh-tight);
  margin: 0;
  /* Two lines, then ellipsis — keeps every card in a row the same height. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-where {
  font-size: var(--t-small);
  color: var(--ink-soft);
  margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card-meta {
  margin-top: auto;
  padding-top: 0.375rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  font-size: var(--t-fine);
  color: var(--ink-faint);
}
.card-meta .dot-sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }

/* ----------------------------------------------------------------- tags -- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: var(--t-fine);
  font-weight: 700;
  letter-spacing: .02em;
  background: var(--cat-bg);
  color: var(--cat-ink);
  border: 1px solid var(--cat-edge);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag .cat-icon { color: var(--cat); flex: 0 0 auto; }

.tag-neutral {
  background: var(--line-soft);
  color: var(--ink-soft);
  border-color: var(--line);
}

.card-badges {
  position: absolute;
  top: 0.5rem; left: 0.5rem; right: 0.5rem;
  display: flex; gap: 0.25rem; align-items: flex-start;
  pointer-events: none;
}
.card-badges .tag { backdrop-filter: blur(6px); box-shadow: 0 1px 2px rgb(0 0 0 / 10%); }

/* ------------------------------------------------------------- calendar -- */

.calendar {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.625rem;
}

.cal-track {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
}
.cal-track::-webkit-scrollbar { height: 6px; }
.cal-track::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* The vertical roll: same markup, stacked. */
.calendar[data-orient=vertical] .cal-track {
  flex-direction: column;
  overflow-x: visible;
  overflow-y: auto;
  max-height: 20rem;
}
.calendar[data-orient=vertical] .cal-day {
  flex-direction: row;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  width: 100%;
}
.calendar[data-orient=vertical] .cal-dots { margin-left: auto; }

.cal-day {
  scroll-snap-align: start;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 4.25rem;
  padding: 0.5rem 0.5rem 0.4375rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.cal-day:hover { background: var(--line-soft); }
.cal-day.is-empty { opacity: .45; }
.cal-day.is-today { border-color: var(--yellow); background: var(--yellow-wash); }
.cal-day.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.cal-day.is-active .cal-dow, .cal-day.is-active .cal-count { color: rgb(255 255 255 / 78%); }

.cal-dow {
  font-size: var(--t-fine);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-faint);
}
.cal-num { font-size: var(--t-h2); font-weight: 700; line-height: 1; }
.cal-count { font-size: var(--t-fine); color: var(--ink-faint); }

.cal-dots { display: flex; flex-wrap: wrap; gap: 2px; min-height: 0.5rem; }
.cal-dot {
  width: 0.4375rem; height: 0.4375rem;
  border-radius: 50%;
  background: var(--cat);
}
.cal-more { font-size: var(--t-fine); color: var(--ink-faint); font-weight: 600; }

/* ---------------------------------------------------------------- lists -- */

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(0.875rem, 2.5vw, 1.25rem);
}

.list-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6875rem 0;
  min-width: 0;
}
.list-row + .list-row { border-top: 1px solid var(--line-soft); }

.avatar {
  flex: 0 0 auto;
  width: 2.25rem; height: 2.25rem;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--green-wash);
  color: var(--green-deep);
  font-weight: 700; font-size: var(--t-small);
}

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  background: var(--paper);
  border-radius: var(--radius-s);
  padding: 0.75rem 0.875rem;
  font-size: var(--t-small);
}
.notice-warm { border-left-color: var(--yellow); background: var(--yellow-wash); }

.empty {
  background: var(--paper);
  border: 1px dashed #d7dce1;
  border-radius: var(--radius);
  padding: clamp(1.25rem, 5vw, 2.25rem);
}
.empty h2 { margin: 0 0 0.375rem; }
.empty p { margin: 0; max-width: 46ch; color: var(--ink-soft); }

/* ------------------------------------------------------------------ map -- */

#map {
  height: clamp(13rem, 42vw, 22rem);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  z-index: 0;
}
.leaflet-container { font: inherit; font-size: var(--t-small); }

/* --------------------------------------------------------------- footer -- */

.etymology {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: var(--t-small);
  color: var(--ink-soft);
}
.etymology .kanji {
  font-size: 1.25rem;
  line-height: 1;
  color: var(--green-deep);
  font-weight: 500;
}
.etymology .romaji { font-style: italic; color: var(--ink-faint); }

.site-footer { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }

/* ----------------------------------------------------------- utilities -- */

.stack > * + * { margin-top: var(--stack-gap, 0.75rem); }
.min0 { min-width: 0; }
.nowrap { white-space: nowrap; }
.truncate-1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .event-card:hover { transform: none; }
}

/* A print of a listing should be the listing, not the furniture. */
@media print {
  .site-header, .nav, .calendar, #map, .chip-scroller, .btn, .btn-quiet { display: none !important; }
  .event-card { break-inside: avoid; box-shadow: none; }
}

/* Map pins carry the category colour, matching the dots and the cards. */
.map-pin span {
  display: block;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--pin, var(--green));
  border: 2.5px solid #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 35%);
}

/* A broken image should leave the category artwork, not a torn icon. */
.card-media.img-failed { background: var(--cat-bg, var(--line-soft)); }

/* A skip link that is never visible helps nobody. Hidden until focused, then
   shown — which is the whole point of it for a sighted keyboard user. */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 1000;
  background: var(--ink);
  color: #fff;
  font-size: var(--t-small);
  font-weight: 650;
  padding: 0.625rem 1rem;
  border-radius: 0 0 var(--radius-s) var(--radius-s);
  text-decoration: none;
  transition: top .12s ease;
}
.skip-link:focus { top: 0; color: #fff; }

/* Long-form prose: narrower measure, roomier rhythm than the app chrome. */
.legal { --stack-gap: 0.875rem; }
.legal p, .legal li { max-width: 62ch; }
.legal ul { padding-left: 1.125rem; margin: 0; }
.legal li + li { margin-top: 0.5rem; }
.legal h2 { font-size: var(--t-h2); }

/* Consent sits next to the button it gates, and is never pre-ticked. */
.consent {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: var(--t-small);
  line-height: 1.45;
  color: var(--ink-soft);
}
.consent input[type="checkbox"] {
  flex: 0 0 auto;
  width: 1.125rem; height: 1.125rem;
  margin: 0.0625rem 0 0;
  accent-color: var(--green);
}
