/* ---------------------------------------------------------------
   Donor plaque wall -- one stylesheet, no framework.
   Palette is deliberately neutral: swap the custom properties below
   for the foundation's brand colours and everything follows.
   --------------------------------------------------------------- */
:root {
  --ink:        #1c1b19;
  --ink-soft:   #55524c;
  --ink-faint:  #8a857c;
  --paper:      #faf8f4;
  --card:       #ffffff;
  --line:       #e2ddd3;

  --brass:      #a8763e;
  --brass-dark: #8a5f2f;
  --slate:      #2f5d62;
  --amber:      #c8890f;

  --available:      #ffffff;
  --available-line: #cfc7b8;
  --sold:           #2f5d62;
  --reserved:       #b9b2a6;
  --pending:        #f0c96a;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(28,27,25,.06), 0 8px 24px rgba(28,27,25,.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2efe9; --ink-soft: #bdb7ad; --ink-faint: #8b857a;
    --paper: #16150f; --card: #211f19; --line: #35322a;
    --available: #2c2922; --available-line: #4a463c;
    --sold: #63a6ac; --reserved: #5b564b; --pending: #b98f27;
    --brass: #d2a26a; --brass-dark: #b98a52;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: -999px; top: 0; z-index: 20;
  background: var(--card); padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

/* ---- masthead ---- */
.masthead {
  display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-end;
  justify-content: space-between;
  padding: clamp(1.25rem, 3vw, 2rem) clamp(1rem, 4vw, 3rem) 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.masthead h1 {
  margin: 0 0 .25rem; font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: -.01em; font-weight: 650;
}
.masthead p { margin: 0; color: var(--ink-soft); max-width: 60ch; }

.progress { min-width: 220px; }
.progress-bar {
  height: 8px; border-radius: 99px; background: var(--line); overflow: hidden;
}
.progress-bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brass), var(--brass-dark));
  transition: width .5s ease;
}
.progress-label { margin: .5rem 0 0; font-size: .875rem; color: var(--ink-soft); }
.progress-label strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---- layout ---- */
/* Map on the left; controls and the selection panel stack down the right.
   Named areas keep the arrangement readable and let the single-column layout
   fall back to plain source order (controls -> map -> detail), which is also
   the tab order -- no `order` tricks that would desync focus from what's on
   screen. */
.layout {
  display: grid; gap: clamp(1rem, 2vw, 2rem);
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  /* The map spans both rows; without an explicit `1fr` second row its height
     would be shared out and push a gap under the controls card. */
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "map controls"
    "map detail";
  align-items: start;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 3rem);
  max-width: 1500px; margin: 0 auto;
}
.controls  { grid-area: controls; }
.map-panel { grid-area: map; }
.detail    { grid-area: detail; }

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "controls" "map" "detail";
  }
}

/* ---- controls card ---- */
.controls {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: clamp(.875rem, 1.6vw, 1.125rem); box-shadow: var(--shadow);
}

/* ---- toolbar ---- */
.toolbar { display: grid; gap: .625rem; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: .625rem; }
.field input, .field select, .form input, .form textarea {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .5rem .75rem; min-height: 42px; width: 100%;
}
.field.search { display: block; }
.field.select { flex: 1 1 150px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible,
[role="button"]:focus-visible, a:focus-visible {
  outline: 2px solid var(--brass); outline-offset: 2px;
}
.toggle {
  display: inline-flex; align-items: center; gap: .5rem; padding: 0 .5rem;
  font-size: .9rem; color: var(--ink-soft); cursor: pointer;
}

/* ---- legend ---- */
.legend {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: .4rem .75rem; font-size: .85rem;
  margin-top: .875rem; padding-top: .875rem; border-top: 1px solid var(--line);
}
.legend span { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink-soft); }
.swatch {
  width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--available-line);
  display: inline-block;
}
.swatch.available { background: var(--available); }
.swatch.sold      { background: var(--sold); border-color: var(--sold); }
.swatch.reserved  { background: var(--reserved); border-color: var(--reserved); }
.swatch.pending   { background: var(--pending); border-color: var(--pending); }

/* ---- map ---- */
.map-frame {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: clamp(.5rem, 2vw, 1.25rem); box-shadow: var(--shadow);
}
#grid { width: 100%; height: auto; display: block; touch-action: manipulation; }

/* On a phone the whole wall shrinks below legibility, so let it overflow and
   be swiped sideways instead of squeezing 36 columns into 390px. */
@media (max-width: 700px) {
  .map-frame { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #grid { min-width: 620px; }
}
.map-hint { margin: .75rem 0 0; font-size: .8rem; color: var(--ink-faint); text-align: center; }

/* font-size is set per element in app.js -- a CSS rule here would win over the
   SVG presentation attribute and break the fit-to-plaque sizing. */
.axis-label { font-family: var(--font); font-weight: 500; fill: var(--ink-faint); text-anchor: middle; }

.plaque {
  fill: var(--available); stroke: var(--available-line); stroke-width: .6;
  cursor: pointer; transition: fill .15s ease, stroke .15s ease, opacity .15s ease;
}
.plaque:hover        { fill: color-mix(in srgb, var(--brass) 18%, var(--available)); stroke: var(--brass); }
.plaque.is-sold      { fill: var(--sold);     stroke: var(--sold);     cursor: default; }
.plaque.is-reserved  { fill: var(--reserved); stroke: var(--reserved); cursor: default; }
.plaque.is-unavailable { fill: var(--reserved); stroke: var(--reserved); opacity: .5; cursor: default; }
.plaque.is-pending   { fill: var(--pending);  stroke: var(--pending); }
.plaque.is-selected  { stroke: var(--brass); stroke-width: 1.6; fill: color-mix(in srgb, var(--brass) 28%, var(--available)); }
.plaque.is-dimmed    { opacity: .18; }
.plaque.is-hit       { stroke: var(--brass); stroke-width: 1.4; }
.plaque-code {
  font-family: var(--mono); font-weight: 500; fill: var(--ink-faint);
  text-anchor: middle; dominant-baseline: central; pointer-events: none;
  user-select: none;
}
.plaque-code.on-dark { fill: rgba(255,255,255,.92); }
.plaque-code.is-dimmed { opacity: .18; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- detail panel ---- */
.detail {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: clamp(1rem, 2vw, 1.5rem); box-shadow: var(--shadow);
  position: sticky; top: 1rem;
}
@media (max-width: 900px) { .detail { position: static; } }
.detail h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.detail p  { margin: 0 0 1rem; color: var(--ink-soft); }

.tier-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.tier-list li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .5rem .625rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: .9rem;
}
.tier-list .amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.tier-list .count { color: var(--ink-faint); font-size: .8rem; }

.plaque-head { display: flex; align-items: baseline; gap: .625rem; margin-bottom: .25rem; }
.plaque-head .code {
  font: 700 1.5rem/1 var(--mono); letter-spacing: -.02em;
}
.badge {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  padding: .2rem .5rem; border-radius: 99px; border: 1px solid var(--line);
  color: var(--ink-soft); white-space: nowrap;
}
.badge.sold      { background: var(--sold); border-color: var(--sold); color: #fff; }
.badge.reserved  { background: var(--reserved); border-color: var(--reserved); color: #fff; }
.badge.available { background: color-mix(in srgb, var(--brass) 15%, transparent); border-color: var(--brass); color: var(--brass-dark); }

.price { font-size: 1.5rem; font-weight: 650; margin: .5rem 0 1rem; font-variant-numeric: tabular-nums; }
.price small { display: block; font-size: .8rem; font-weight: 400; color: var(--ink-faint); }

.form { display: grid; gap: .625rem; }
.form label { display: grid; gap: .25rem; font-size: .85rem; color: var(--ink-soft); }
.form textarea { min-height: 72px; resize: vertical; }
.form .row { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.form .row input { width: auto; min-height: 0; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: var(--radius);
  padding: .7rem 1.1rem; min-height: 44px; cursor: pointer;
  background: var(--brass); color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
}
.btn:hover { background: var(--brass-dark); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--paper); }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; }

.notice {
  border-radius: var(--radius); padding: .75rem .875rem; font-size: .875rem;
  border: 1px solid var(--line); background: var(--paper); margin: 0 0 .75rem;
}
.notice.error  { border-color: #d4644a; background: color-mix(in srgb, #d4644a 10%, transparent); }
.notice.good   { border-color: var(--slate); background: color-mix(in srgb, var(--slate) 10%, transparent); }
.countdown { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- receipt / centered pages ---- */
.centered { display: grid; place-items: center; min-height: 100dvh; padding: 2rem 1rem; }
.receipt {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 2rem; max-width: 34rem; box-shadow: var(--shadow);
}
.receipt h1 { margin-top: 0; }
.receipt dl { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 1rem 0 1.5rem; }
.receipt dt { color: var(--ink-faint); font-size: .85rem; }
.receipt dd { margin: 0; }

.footer {
  padding: 2rem clamp(1rem, 4vw, 3rem); border-top: 1px solid var(--line);
  font-size: .85rem; color: var(--ink-soft);
}
.muted { color: var(--ink-faint); }
code { font-family: var(--mono); font-size: .9em; }
