/* UI layer — TemplatePeakDesign, via CSS custom properties.
   The UI never hardcodes colors or fonts: ui.js fetches /api/v1/theme and
   sets every --tpd-* variable from the shared definition. This file owns
   layout, spacing, motion and elevation only (LAYERS.UI OWNS theme_css). */

:root {
  --tpd-blush: #f2c4ce; --tpd-blush-light: #faf0f2;
  --tpd-gold: #c9a96e; --tpd-gold-light: #f7ead0; --tpd-gold-dark: #9b7b42;
  --tpd-white: #ffffff; --tpd-cream: #fffdf7;
  --tpd-text-dark: #2c1810; --tpd-text-mid: #6b4226; --tpd-text-light: #a07860;
  --tpd-input-blue: #d6e4f7;
  --tpd-font-heading: Georgia, serif;
  --tpd-font-body: system-ui, sans-serif;

  /* layout tokens (presentation only) */
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(44, 24, 16, .06);
  --shadow: 0 8px 28px -12px rgba(44, 24, 16, .22);
  --shadow-lg: 0 22px 50px -20px rgba(44, 24, 16, .30);
  --ring: 0 0 0 3px rgba(201, 169, 110, .35);
  --maxw: 1000px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--tpd-font-body);
  color: var(--tpd-text-dark);
  background:
    radial-gradient(1200px 380px at 50% -120px, var(--tpd-blush-light), transparent 70%),
    var(--tpd-cream);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .heading {
  font-family: var(--tpd-font-heading);
  color: var(--tpd-gold-dark);
  font-weight: 600;
  letter-spacing: .2px;
  line-height: 1.2;
}
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.35rem; margin: 0 0 .6rem; }
h3 { font-size: 1.08rem; color: var(--tpd-text-mid); margin: 1.4rem 0 .5rem; }

a { color: var(--tpd-gold-dark); text-underline-offset: 3px; }

/* ── header ── */
header.site {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: .85rem clamp(1rem, 4vw, 2rem);
  background: rgba(255, 253, 247, .82);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--tpd-gold-light);
}
header.site h1 {
  font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  display: flex; align-items: center; gap: .55rem;
}
header.site h1::before {
  content: "❦"; color: var(--tpd-blush);
  font-size: 1.2em; line-height: 1;
}
header.site > div { display: flex; align-items: center; gap: .6rem; }

main { max-width: var(--maxw); margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }

/* ── hero (login) ── */
.hero {
  text-align: center; padding: 2.4rem 1rem 1.4rem;
}
.hero .kicker {
  text-transform: uppercase; letter-spacing: 3px; font-size: .72rem;
  color: var(--tpd-text-light);
}
.hero h2 {
  font-size: clamp(1.8rem, 5vw, 2.8rem); color: var(--tpd-gold-dark);
  margin: .3rem 0 .2rem;
}
.hero .rule {
  width: 64px; height: 2px; margin: .9rem auto;
  background: linear-gradient(90deg, transparent, var(--tpd-gold), transparent);
}

/* ── cards ── */
.card {
  background: var(--tpd-white);
  border: 1px solid var(--tpd-gold-light);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.5vw, 1.6rem);
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 460px; margin-inline: auto; }

/* ── metrics ── */
.metric {
  display: inline-flex; align-items: baseline; gap: .4rem;
  background: linear-gradient(180deg, var(--tpd-white), var(--tpd-gold-light));
  color: var(--tpd-gold-dark);
  border: 1px solid var(--tpd-gold-light);
  border-radius: 999px;
  padding: .5rem .95rem; margin: 0 .5rem .5rem 0;
  font-weight: 600; font-size: .92rem;
  box-shadow: var(--shadow-sm);
}

/* ── forms ── */
label { display: block; margin: .7rem 0 .25rem; color: var(--tpd-text-mid); font-size: .92rem; }
input, select, textarea {
  width: 100%; padding: .62rem .8rem;
  border: 1px solid #e7d9c9; border-radius: var(--radius-sm);
  background: var(--tpd-white);
  font: inherit; color: var(--tpd-text-dark);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--tpd-gold); box-shadow: var(--ring);
  background: var(--tpd-white);
}
input[readonly] { background: var(--tpd-blush-light); color: var(--tpd-text-mid); }

/* ── buttons ── */
button {
  background: var(--tpd-gold-dark); color: var(--tpd-white);
  font-family: var(--tpd-font-heading); font-size: .98rem; letter-spacing: .3px;
  border: 0; border-radius: var(--radius-sm);
  padding: .6rem 1.25rem; margin-top: .9rem;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
button:hover { background: var(--tpd-gold); box-shadow: var(--shadow); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .55; cursor: default; box-shadow: none; }
button.ghost {
  background: transparent; color: var(--tpd-gold-dark);
  border: 1px solid var(--tpd-gold-light);
}
button.ghost:hover { background: var(--tpd-blush-light); }

/* secondary buttons in header are lighter */
header.site button {
  background: transparent; color: var(--tpd-gold-dark);
  border: 1px solid var(--tpd-gold-light); margin-top: 0;
  padding: .42rem .9rem; font-size: .9rem;
}
header.site button:hover { background: var(--tpd-blush-light); }
header.site select { width: auto; padding: .4rem .6rem; }

/* ── tables ── */
table { width: 100%; border-collapse: collapse; margin-top: .5rem; font-size: .95rem; }
th {
  background: var(--tpd-gold-dark); color: var(--tpd-white);
  font-family: var(--tpd-font-heading); font-weight: 600;
  padding: .6rem .65rem; text-align: left; white-space: nowrap;
}
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }
td { padding: .55rem .65rem; border-bottom: 1px solid var(--tpd-blush-light); }
tbody tr:nth-child(even) { background: var(--tpd-cream); }
tbody tr:hover { background: var(--tpd-blush-light); }
td button { margin-top: 0; padding: .3rem .65rem; font-size: .82rem; }

/* ── tabs ── */
nav.tabs {
  display: flex; flex-wrap: wrap; gap: .4rem;
  margin: 1rem 0 1.2rem; padding-bottom: .3rem;
}
nav.tabs button {
  background: var(--tpd-white); color: var(--tpd-text-mid);
  border: 1px solid var(--tpd-gold-light); margin-top: 0;
  padding: .48rem 1rem; border-radius: 999px; font-size: .92rem;
  box-shadow: none;
}
nav.tabs button:hover { background: var(--tpd-blush-light); color: var(--tpd-gold-dark); }
nav.tabs button[aria-selected="true"] {
  background: linear-gradient(180deg, var(--tpd-blush-light), var(--tpd-gold-light));
  color: var(--tpd-gold-dark); border-color: var(--tpd-gold);
  box-shadow: var(--shadow-sm);
}

/* ── chips / tags ── */
.tag {
  display: inline-block;
  background: var(--tpd-blush-light); color: var(--tpd-text-mid);
  border: 1px solid var(--tpd-gold-light);
  border-radius: 999px; padding: .12rem .6rem; font-size: .82rem;
}

/* ── misc ── */
.notice { color: var(--tpd-text-light); }
.subtle { font-size: .85rem; }
.error { color: #b71c1c; }
.ok { color: #1b5e20; }

.empty {
  text-align: center; color: var(--tpd-text-light);
  padding: 1.6rem 1rem; border: 1px dashed var(--tpd-gold-light);
  border-radius: var(--radius-sm); background: var(--tpd-cream);
}

progress {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 12px; border: 0; border-radius: 999px;
  background: var(--tpd-blush-light); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--tpd-blush-light); }
progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--tpd-gold), var(--tpd-gold-dark)); border-radius: 999px;
}
progress::-moz-progress-bar { background: var(--tpd-gold-dark); }

/* a gentle entrance for cards */
@media (prefers-reduced-motion: no-preference) {
  .card { animation: rise .4s cubic-bezier(.2, .7, .3, 1) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* ── responsive ── */
@media (max-width: 560px) {
  header.site { flex-wrap: wrap; }
  .metric { width: 100%; justify-content: space-between; }
  table { font-size: .85rem; }
  th, td { padding: .45rem .4rem; }
}

/* ── print — any tab becomes a clean handout (issue #40) ── */
@media print {
  header.site, nav.tabs, .grid-form, #export-result,
  button, select:not(:disabled), input[type="file"],
  #public-rsvp-off, #public-rsvp-on, #ov-empty, .notice.subtle { display: none !important; }
  body { background: #fff; }
  .card {
    box-shadow: none; border: 1px solid #ddd;
    break-inside: avoid; animation: none;
  }
  section.tab { display: none; }
  section.tab.active { display: block; }
  table select { display: inline !important; border: 0; background: none; appearance: none; }
  td input[type="checkbox"] { appearance: auto; }
  a[href]::after { content: ""; }
  progress { border: 1px solid #ccc; }
}

/* Legal footer — present on every page (privacy/terms/support reachability). */
footer.legal-links {
  max-width: var(--maxw);
  margin: 2.5rem auto 1.5rem;
  padding: 1rem clamp(1rem, 3vw, 2rem) 0;
  border-top: 1px solid var(--tpd-gold-light);
  text-align: center;
  font-size: .85rem;
  color: var(--tpd-text-light);
}
@media print { footer.legal-links { display: none; } }
