/* ============================================================
   XC Social — "flyer wall" visual system
   Bold & vibrant events-app look: Anton marquee display + Hanken
   Grotesk body; saturated poster-ink plan cards color-coded by
   category; chunky pill controls.

   Tokens carry the theme. Plan cards are self-saturated (always an
   ink fill with near-white text) in BOTH modes; the surrounding
   chrome (ground, surfaces, text) flips light/dark.
   ============================================================ */

/* ---------- Tokens: light ---------- */
:root {
  --paper:        #fbf7ef;   /* page ground */
  --surface:      #ffffff;   /* raised cards, header, nav */
  --surface-2:    #f2ece0;
  --surface-sunk: #e9e1d2;

  --ink:          #191410;   /* primary text */
  --ink-soft:     #5c5346;   /* secondary text */
  --muted:        #8a7d68;
  --line:         #e7ded0;
  --line-strong:  #d8cdb8;

  /* Poster inks — category coding. Same values in both themes. */
  --tangerine: #ff5a1f;
  --pink:      #ff2e7e;
  --cobalt:    #2440e8;
  --violet:    #6e2cf2;
  --grass:     #17a85a;

  --accent:       var(--tangerine);
  --accent-text:  #b5350d;   /* tangerine dark enough for text on paper */
  --on-ink:       #fbf7ef;   /* text/icons on a saturated ink fill */

  --going:        #0f7a44;
  --going-soft:   #e3f5ea;
  --warn:         #b45309;
  --danger:       #d11f3f;
  --danger-soft:  #fde8ec;

  --display: "Anton", Impact, "Haettenschweiler", system-ui, sans-serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --fs-xs: .75rem; --fs-sm: .875rem; --fs-base: 1rem; --fs-lg: 1.125rem;
  --fs-xl: 1.375rem; --fs-2xl: 1.75rem;

  --sp-1:.25rem; --sp-2:.5rem; --sp-3:.75rem; --sp-4:1rem; --sp-5:1.5rem; --sp-6:2rem;
  --radius: 12px; --radius-lg: 22px; --radius-pill: 999px;
  --shadow-1: 0 1px 0 var(--line-strong);
  --shadow-2: 0 14px 30px -18px rgba(40,28,10,.5);

  --header-h: 56px; --nav-h: 64px;
}

/* ---------- Tokens: dark ---------- */
:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --paper:#14110d; --surface:#1e1a15; --surface-2:#26211a; --surface-sunk:#0e0b08;
    --ink:#fbf7ef; --ink-soft:#b8ad9a; --muted:#8f8571; --line:#2e2820; --line-strong:#3a3226;
    --accent-text:#ff7a45;
    --going:#34d399; --going-soft:#123023; --warn:#fbbf24; --danger:#ff6b83; --danger-soft:#2c1218;
    --shadow-1: 0 1px 0 #000; --shadow-2: 0 16px 34px -18px rgba(0,0,0,.8);
  }
}
:root[data-theme="dark"] {
  --paper:#14110d; --surface:#1e1a15; --surface-2:#26211a; --surface-sunk:#0e0b08;
  --ink:#fbf7ef; --ink-soft:#b8ad9a; --muted:#8f8571; --line:#2e2820; --line-strong:#3a3226;
  --accent-text:#ff7a45;
  --going:#34d399; --going-soft:#123023; --warn:#fbbf24; --danger:#ff6b83; --danger-soft:#2c1218;
  --shadow-1: 0 1px 0 #000; --shadow-2: 0 16px 34px -18px rgba(0,0,0,.8);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--sans); font-size: var(--fs-base); line-height: 1.5;
  color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,p,figure { margin: 0; }
ul,ol { margin: 0; padding: 0; list-style: none; }
img,svg,video { display: block; max-width: 100%; }
button,input,select,textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; font-weight: 700; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration:.01ms!important; transition-duration:.01ms!important; } }

/* ---------- Header ---------- */
.app-header {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  height: calc(var(--header-h) + env(safe-area-inset-top,0px));
  padding: env(safe-area-inset-top,0px) var(--sp-4) 0;
  background: var(--surface); border-bottom: 2px solid var(--ink);
}
.app-header__title {
  font-family: var(--display); font-weight: 400; font-size: 1.5rem;
  text-transform: uppercase; letter-spacing: .04em; line-height: 1;
}
.app-header__actions { display: flex; gap: var(--sp-2); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; background: transparent;
  border: 2px solid var(--line); border-radius: var(--radius); color: var(--ink-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.icon-btn__glyph { font-size: var(--fs-lg); line-height: 1; }

/* ---------- Main ---------- */
.app-main {
  padding: calc(var(--header-h) + env(safe-area-inset-top,0px) + var(--sp-4)) var(--sp-4)
           calc(var(--nav-h) + env(safe-area-inset-bottom,0px) + var(--sp-6));
  max-width: 480px; margin: 0 auto;
}
.app-main:focus { outline: none; }

/* ---------- Bottom nav ---------- */
.app-nav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4,1fr); align-items: center;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom,0px));
  padding-bottom: env(safe-area-inset-bottom,0px);
  background: var(--surface); border-top: 2px solid var(--ink);
}
.app-nav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 48px; color: var(--ink-soft); text-decoration: none; font-weight: 700;
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
}
.app-nav__item:hover { text-decoration: none; color: var(--ink); }
.app-nav__item[aria-current="page"] { color: var(--accent-text); }
.app-nav__glyph { font-size: var(--fs-lg); line-height: 1; }
/* Create = the marquee "+" tile */
.app-nav__item[data-route="create"] .app-nav__glyph {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 40px; margin-top: -6px;
  background: var(--ink); color: var(--surface); border-radius: 12px; font-size: 26px;
}
.app-nav__item[data-route="create"][aria-current="page"] .app-nav__glyph { background: var(--accent); color: var(--on-ink); }

/* ---------- Views / headings ---------- */
.view__title {
  font-family: var(--display); font-weight: 400; font-size: 3rem; line-height: .9;
  text-transform: uppercase; letter-spacing: .01em; text-wrap: balance; margin-bottom: var(--sp-1);
}
.view__lede { color: var(--ink-soft); font-weight: 600; margin-bottom: var(--sp-5); }

.card {
  background: var(--surface); border: 2px solid var(--ink);
  border-radius: var(--radius-lg); padding: var(--sp-4); box-shadow: var(--shadow-2);
}
.card + .card { margin-top: var(--sp-3); }

.placeholder {
  display: grid; place-items: center; gap: var(--sp-3); text-align: center;
  padding: var(--sp-6) var(--sp-4); color: var(--ink-soft);
  background: var(--surface-2); border: 2px dashed var(--line-strong); border-radius: var(--radius-lg);
}
.placeholder strong { font-family: var(--display); font-weight: 400; font-size: 1.5rem; text-transform: uppercase; color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 48px; padding: var(--sp-2) var(--sp-5);
  font-weight: 800; font-size: var(--fs-base); letter-spacing: .02em;
  border: 2px solid var(--ink); border-radius: var(--radius-pill); cursor: pointer;
  background: var(--surface); color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: var(--on-ink); border-color: var(--ink); }
.btn--primary:hover { background: #e94e15; }
.btn--going { background: var(--going); color: #fff; border-color: var(--ink); }
.btn--block { width: 100%; }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); margin-top: var(--sp-4); }
.btn--danger-ghost:hover { background: var(--danger-soft); }

/* ---------- Forms ---------- */
.field { margin-bottom: var(--sp-4); }
.field__label { display: block; margin-bottom: var(--sp-1); font-size: var(--fs-sm); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.field__hint { display: block; margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--muted); }
.input {
  display: block; width: 100%; min-height: 48px; padding: var(--sp-2) var(--sp-3);
  background: var(--surface); color: var(--ink); font-weight: 600;
  border: 2px solid var(--ink); border-radius: var(--radius);
}
.input:focus-visible { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cobalt) 30%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 88px; }
.field-check { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-2) 0 var(--sp-4); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); }
.field-error { display: block; margin-top: var(--sp-1); font-size: var(--fs-sm); font-weight: 700; color: var(--danger); }
.notice { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); font-size: var(--fs-sm); font-weight: 700; border: 2px solid transparent; }
.notice--error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.notice--info { background: var(--surface-2); color: var(--accent-text); border-color: var(--accent); }

/* ---------- Chips: time tabs + scope ---------- */
.chip-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.chip-row--scope { margin-bottom: var(--sp-4); }
.chip {
  min-height: 42px; padding: var(--sp-2) var(--sp-4); font-weight: 800; font-size: var(--fs-sm);
  color: var(--ink); background: transparent; border: 2px solid var(--ink);
  border-radius: var(--radius-pill); cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.chip--scope { min-height: 36px; padding: var(--sp-1) var(--sp-3); border-color: var(--line-strong); color: var(--ink-soft); }
.chip--scope[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-text); background: var(--surface); }

/* ---------- Feed: flyer cards ---------- */
.feed-results { display: flex; flex-direction: column; gap: var(--sp-4); }

.card-plan {
  --fill: var(--tangerine);              /* default ink; overridden per category */
  display: block; width: 100%; text-align: left; cursor: pointer; font: inherit;
  background: var(--fill); color: var(--on-ink);
  border: 2px solid var(--ink); border-radius: var(--radius-lg);
  padding: var(--sp-4); box-shadow: var(--shadow-2);
}
.card-plan:hover { transform: translateY(-2px); }
.card-plan:active { transform: translateY(0); }

/* category → poster ink */
.card-plan[data-cat="music"]   { --fill: var(--violet); }
.card-plan[data-cat="arts"]    { --fill: var(--pink); }
.card-plan[data-cat="nightlife"]{ --fill: var(--pink); }
.card-plan[data-cat="sports"]  { --fill: var(--cobalt); }
.card-plan[data-cat="fitness"] { --fill: var(--cobalt); }
.card-plan[data-cat="gaming"]  { --fill: var(--cobalt); }
.card-plan[data-cat="makers"]  { --fill: var(--cobalt); }
.card-plan[data-cat="study"]   { --fill: var(--violet); }
.card-plan[data-cat="outdoors"]{ --fill: var(--grass); }
.card-plan[data-cat="faith"]   { --fill: var(--grass); }
.card-plan[data-cat="volunteering"]{ --fill: var(--grass); }
.card-plan[data-cat="food"]    { --fill: var(--tangerine); }
.card-plan[data-cat="market"]  { --fill: var(--tangerine); }
.card-plan[data-cat="social"]  { --fill: var(--tangerine); }
/* civic is deliberately un-boosted (§1.4.3): restrained neutral, not a vivid poster */
.card-plan[data-cat="civic"]   { --fill: var(--ink); }
.card-plan[data-cat="other"]   { --fill: var(--ink); }

.card-plan__when {
  font-family: var(--display); font-weight: 400; font-size: 1.25rem; line-height: 1;
  text-transform: uppercase; letter-spacing: .02em; color: var(--on-ink); margin-bottom: var(--sp-1);
}
.card-plan__title {
  font-family: var(--display); font-weight: 400; font-size: 1.9rem; line-height: .92;
  text-transform: uppercase; text-wrap: balance; margin-bottom: var(--sp-2); color: var(--on-ink);
}
.card-plan__place { font-weight: 600; font-size: var(--fs-sm); color: var(--on-ink); opacity: .92; }
.card-plan__foot { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); flex-wrap: wrap; }
.card-plan__going { font-weight: 800; font-size: var(--fs-sm); color: var(--on-ink); }
.card-plan__you { font-weight: 800; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--ink); background: var(--on-ink); padding: 3px var(--sp-2); border-radius: var(--radius-pill); }
.card-plan__you--maybe { color: var(--on-ink); background: transparent; border: 2px solid var(--on-ink); }
.card-plan__badges { margin-left: auto; display: flex; gap: var(--sp-1); }

.badge {
  font-weight: 800; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink); background: var(--on-ink); padding: 3px var(--sp-2); border-radius: var(--radius-pill);
}
.badge--21 { color: var(--on-ink); background: var(--ink); }

/* ---------- Compose ---------- */
.compose .chip[aria-selected="true"] { background: var(--accent); color: var(--on-ink); border-color: var(--ink); }
.profile-edit { margin-bottom: var(--sp-3); }

.typeahead { border: 2px solid var(--ink); border-radius: var(--radius); margin-top: var(--sp-1); overflow: hidden; background: var(--surface); }
.typeahead__item { display: block; width: 100%; text-align: left; padding: var(--sp-2) var(--sp-3); background: transparent; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.typeahead__item:last-child { border-bottom: 0; }
.typeahead__item:hover { background: var(--surface-2); }
.typeahead__name { display: block; font-weight: 800; }
.typeahead__meta { display: block; font-size: var(--fs-xs); color: var(--muted); }
.typeahead__empty { padding: var(--sp-3); color: var(--muted); font-size: var(--fs-sm); }
.place-chosen { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-1); padding: var(--sp-2) var(--sp-3); background: var(--surface-2); border: 2px solid var(--ink); border-radius: var(--radius); }
.place-chosen__name { font-weight: 800; }
.link-clear { margin-left: auto; background: none; border: 0; color: var(--accent-text); font-weight: 800; cursor: pointer; }

/* ---------- Plan detail ---------- */
.link-back { display: inline-flex; align-items: center; gap: var(--sp-1); min-height: 40px; padding: 0 var(--sp-2) 0 0; margin-bottom: var(--sp-2); background: none; border: 0; color: var(--ink-soft); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: var(--fs-sm); cursor: pointer; }
.link-back:hover { color: var(--ink); }
.detail__when { font-family: var(--display); font-weight: 400; font-size: 1.25rem; text-transform: uppercase; letter-spacing: .02em; color: var(--accent-text); }
.detail__title { font-family: var(--display); font-weight: 400; font-size: 2.6rem; line-height: .92; text-transform: uppercase; text-wrap: balance; margin: var(--sp-1) 0 var(--sp-2); }
.detail__place { font-size: var(--fs-lg); font-weight: 800; }
.detail__addr { color: var(--ink-soft); font-size: var(--fs-sm); font-weight: 600; }
.detail__by { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; margin-top: var(--sp-1); }
.detail__badges { display: flex; gap: var(--sp-1); margin-top: var(--sp-3); }
.detail__badges .badge { background: var(--surface-2); color: var(--ink); border: 2px solid var(--ink); }
.detail__badges .badge--21 { background: var(--ink); color: var(--on-ink); }
.detail__desc { margin-top: var(--sp-4); color: var(--ink); font-weight: 500; white-space: pre-wrap; line-height: 1.6; }
.detail__count { margin-top: var(--sp-5); font-size: var(--fs-lg); font-weight: 700; color: var(--ink-soft); }
.detail__count strong { font-family: var(--display); font-weight: 400; font-size: 1.6rem; color: var(--going); vertical-align: -2px; }
.detail__subhead { margin-top: var(--sp-5); margin-bottom: var(--sp-3); font-family: var(--display); font-weight: 400; font-size: 1.4rem; text-transform: uppercase; letter-spacing: .02em; }

.detail__rsvp { margin-top: var(--sp-4); }
.rsvp { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--sp-2); }
.rsvp-btn { min-height: 52px; border: 2px solid var(--ink); background: var(--surface); font-weight: 800; }
.rsvp-btn[aria-pressed="true"].rsvp-btn--in    { background: var(--going); color: #fff; }
.rsvp-btn[aria-pressed="true"].rsvp-btn--maybe { background: var(--warn); color: #fff; }
.rsvp-btn[aria-pressed="true"].rsvp-btn--out   { background: var(--surface-sunk); color: var(--ink); }

.attendees { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.attendee { font-weight: 700; font-size: var(--fs-sm); padding: var(--sp-1) var(--sp-3); background: var(--going-soft); color: var(--going); border: 2px solid var(--going); border-radius: var(--radius-pill); }
.attendee--maybe { background: var(--surface-2); color: var(--ink-soft); border-color: var(--line-strong); }
.attendees__note { color: var(--muted); font-weight: 600; }

/* ---------- Detail list (profile) ---------- */
.detail-list__row { display: flex; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.detail-list__row:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; font-weight: 800; }

/* ---------- Auth tabs ---------- */
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-1); margin-bottom: var(--sp-4); padding: var(--sp-1); background: var(--surface-2); border: 2px solid var(--ink); border-radius: var(--radius-pill); }
.auth-tab { min-height: 42px; padding: var(--sp-2) var(--sp-3); font-weight: 800; font-size: var(--fs-sm); color: var(--ink-soft); background: transparent; border: 0; border-radius: var(--radius-pill); cursor: pointer; }
.auth-tab[aria-selected="true"] { background: var(--accent); color: var(--on-ink); }
.auth-form .notice { margin-bottom: var(--sp-4); }

/* ---------- Toasts ---------- */
.toast-host {
  position: fixed; z-index: 40; left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom,0px) + var(--sp-4));
  transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--sp-2);
  width: min(92vw, 440px); pointer-events: none;
}
.toast { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--ink); color: var(--paper); font-weight: 700; font-size: var(--fs-sm); box-shadow: var(--shadow-2); border: 2px solid var(--ink); }
.toast--error { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---------- Utility ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (min-width: 768px) {
  :root { --header-h: 64px; }
  .app-main { padding-top: calc(var(--header-h) + var(--sp-6)); }
}
