/* Self-hosted brand type — shared with putisi-purchasing so both sites read
   as the same organization. Files copied verbatim from that project; do not
   regenerate the Noto Serif TC subset here, keep it in sync with the source
   (scripts/subset-cjk-font.mjs lives in ~/Claude/Putisi/purchasing). */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/cormorant-garamond-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/cormorant-garamond-latin-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/cormorant-garamond-latin-500-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Spectral";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/spectral-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Spectral";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/spectral-latin-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Spectral";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/spectral-latin-500-normal.woff2") format("woff2");
}
@font-face {
  /* Utility/mono accent — matches hkgala2026.buddhisttemple.ca (same design
     family: identical bloom-gradient background and card tokens confirmed
     by direct inspection). Used only for small labels and button/link
     English text; Chinese in those elements falls back to the serif stack
     automatically since this face has no CJK glyphs. */
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Serif TC Subset";
  src: url("/fonts/noto-serif-tc-subset.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FF00-FFEF;
}

:root {
  /* paper / ground */
  --paper: #F3EAD8;
  --paper-2: #EADFC8;
  --card: #FBF6EC;

  /* ink (deep sepia) */
  --ink: #3B2A18;
  --ink-2: #5C4630;
  --ink-soft: #725C3D;

  /* aged gold — the everyday accent */
  --gold: #B58A3C;
  --gold-deep: #94702C;
  --gold-pale: #D8BE86;

  /* cinnabar — reserved for the sacred/urgent mark: inauspicious stars,
     duplicate warnings, destructive actions. Never decorative. */
  --cinnabar: #9E2B23;
  --cinnabar-deep: #7E211B;

  --line: #D7C6A6;
  --line-soft: #E3D6BB;

  --bloom-1: rgba(255, 250, 236, .9);
  --bloom-2: rgba(216, 190, 134, .28);

  --r-sm: 6px;
  --r: 14px;
  --r-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(93, 66, 33, .08);
  --shadow: 0 12px 34px rgba(93, 66, 33, .14);

  --measure: 46rem;

  --serif: "Cormorant Garamond", "Noto Serif TC Subset", "Noto Serif TC", Georgia, serif;
  --body: "Spectral", "Noto Serif TC Subset", "Noto Serif TC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "Noto Serif TC Subset", "Noto Serif TC", ui-monospace, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #211A12;
    --paper-2: #1A140D;
    --card: #2A2117;
    --ink: #ECE1CE;
    --ink-2: #CDBFA5;
    --ink-soft: #A08A6C;
    --gold: #C9A44A;
    --gold-deep: #B8954A;
    --gold-pale: #6B5A34;
    --cinnabar: #D2776A;
    --cinnabar-deep: #A8463A;
    --line: #4A3D2A;
    --line-soft: #382D1F;
    --bloom-1: transparent;
    --bloom-2: transparent;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    --shadow: 0 12px 34px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #211A12;
  --paper-2: #1A140D;
  --card: #2A2117;
  --ink: #ECE1CE;
  --ink-2: #CDBFA5;
  --ink-soft: #A08A6C;
  --gold: #C9A44A;
  --gold-deep: #B8954A;
  --gold-pale: #6B5A34;
  --cinnabar: #D2776A;
  --cinnabar-deep: #A8463A;
  --line: #4A3D2A;
  --line-soft: #382D1F;
  --bloom-1: transparent;
  --bloom-2: transparent;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
  --shadow: 0 12px 34px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0;
  background:
    radial-gradient(120% 90% at 92% 4%, var(--bloom-1), transparent 46%),
    radial-gradient(80% 70% at 88% 30%, var(--bloom-2), transparent 55%),
    linear-gradient(150deg, var(--paper) 0%, var(--paper-2) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.7;
  font-feature-settings: "onum" 1;
  overflow-wrap: break-word;
}
img { max-width: 100%; }

h1, h2, h3 { line-height: 1.15; color: var(--ink); }
h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 3.2vw, 2.6rem);
  margin: .2em 0 .5em;
}
h2 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: .02em;
  font-variant-caps: all-small-caps;
  color: var(--gold-deep);
  font-size: 1.35rem;
  margin: 2rem 0 .3rem;
}
h2::after {
  content: "";
  display: block;
  width: 3rem;
  height: 2px;
  background: var(--gold);
  margin-top: .4rem;
}
h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-2);
  margin: 1.4rem 0 .2rem;
}

a { color: var(--ink); text-decoration-color: var(--gold); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.skip-link { position: absolute; left: -9999px; z-index: 10; }
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  background: var(--card);
  padding: .5rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }

/* ---- header / nav ----
   Mobile-first: collapsed to a hamburger toggle by default (matches
   flamingmouth.ddmhk.org.hk's "選單" pattern — toggle + brand in one bar,
   the rest of the links and the account block live in a panel that drops
   open below it). At >=720px the bar's toggle disappears (display:none, so
   it doesn't occupy space) and `.nav__bar` becomes `display:contents` so
   the brand and the (now always-open) menu sit in one row like before. */
nav {
  background: var(--paper-2);
  border-bottom: 1px solid var(--gold-pale);
  padding: .85rem 1.25rem;
  display: flex;
  flex-direction: column;
}
.nav__bar {
  display: flex;
  align-items: center;
  gap: .85rem;
}
.nav__toggle {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: .5rem .9rem;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
}
.nav__toggle:hover { border-color: var(--gold); color: var(--ink); }
.nav__toggle-icon { font-size: 1rem; line-height: 1; }
.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
}
.nav__logo {
  display: block;
  flex: none;
  height: 26px;
  width: calc(26px * 4.04);
  background: var(--ink);
  -webkit-mask: url("/images/logo-lockup.png") no-repeat left center / contain;
  mask: url("/images/logo-lockup.png") no-repeat left center / contain;
}
.nav__name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--ink);
  white-space: nowrap;
}
.nav__menu {
  display: flex;
  flex-direction: column;
  margin-top: .9rem;
  padding-top: .85rem;
  border-top: 1px solid var(--gold-pale);
}
.nav__menu[hidden] { display: none; }
.nav__menu a {
  color: var(--ink-2);
  text-decoration: none;
  font-family: var(--sans);
  font-size: .95rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.nav__menu a:hover { color: var(--ink); }
.nav__account {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .6rem;
  margin-top: .9rem;
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--ink-soft);
}

@media (min-width: 720px) {
  nav { flex-direction: row; align-items: center; gap: 1.25rem; }
  .nav__bar { display: contents; }
  .nav__toggle { display: none; }
  .nav__menu[hidden] { display: flex; }
  .nav__menu {
    flex: 1;
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }
  .nav__menu a {
    padding: 0;
    border-bottom: 1px solid transparent;
    letter-spacing: .01em;
  }
  .nav__menu a:hover { border-bottom-color: var(--gold); }
  .nav__account {
    flex-direction: row;
    align-items: center;
    gap: .6rem;
    margin-top: 0;
    margin-left: auto;
  }
}

/* ---- layout ---- */
main { max-width: var(--measure); margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.auth-page {
  max-width: 22rem;
  margin: 4.5rem auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
}
.auth-page h1 { text-align: center; margin-bottom: 1.25rem; }

/* ---- forms ---- */
label {
  display: block;
  margin-bottom: 1.1rem;
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .04em;
  color: var(--ink-soft);
}
input, select, textarea {
  width: 100%;
  padding: .6rem .8rem;
  margin-top: .4rem;
  font-family: var(--body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-deep); outline-offset: 1px; border-color: var(--gold-deep); }
textarea { min-height: 5rem; resize: vertical; }
fieldset {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem 1.5rem;
  margin: 1.5rem 0;
}
legend { font-family: var(--mono); font-size: .72rem; letter-spacing: .04em; color: var(--ink-soft); padding: 0 .4rem; }

/* Pill buttons with a gold gradient — matches hkgala2026's CTA style.
   English/digits render in JetBrains Mono; CJK falls back to the serif
   stack automatically since that face has no CJK glyphs. */
button {
  font-family: var(--mono);
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .01em;
  padding: .7rem 1.6rem;
  cursor: pointer;
  background: linear-gradient(150deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: var(--paper);
  border: 1px solid var(--gold-deep);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
button:hover { background: linear-gradient(150deg, var(--gold-deep) 0%, var(--ink-2) 100%); border-color: var(--ink-2); }
.person-row button, nav form button {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
}
.person-row button:hover, nav form button:hover { color: var(--ink); border-color: var(--gold); background: transparent; }
/* Log out sits next to plain sans nav links ("Signed in as ...") — match
   their font instead of the mono CTA treatment so the bar reads as one
   typeface family, not three. */
nav form button {
  font-family: var(--sans);
  font-weight: 400;
  font-size: .85rem;
  letter-spacing: normal;
}

/* ---- tables ---- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; background: var(--card); border-radius: var(--r); overflow: hidden; }
th {
  font-family: var(--sans);
  font-size: .78rem;
  letter-spacing: .03em;
  text-transform: none;
  font-variant-caps: all-small-caps;
  color: var(--gold-deep);
  text-align: left;
  padding: .6rem .8rem;
  border-bottom: 2px solid var(--gold-pale);
}
td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line-soft); }
tr:last-child td { border-bottom: none; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable::after { content: '\2195'; margin-left: .3em; opacity: .35; font-size: .85em; }
th.sortable.sort-asc::after { content: '\2191'; opacity: 1; }
th.sortable.sort-desc::after { content: '\2193'; opacity: 1; }
tr.filters th { padding: .35rem .5rem; border-bottom: 1px solid var(--line-soft); }
#records-count { font-family: var(--mono); font-size: .76rem; color: var(--ink-soft); }
tr.filters input, tr.filters select {
  width: 100%;
  font-size: .82rem;
  padding: .3rem .5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

/* ---- messages ---- */
.error { color: var(--cinnabar-deep); font-family: var(--sans); font-size: .92rem; }
.warning {
  background: var(--card);
  border: 1px solid var(--cinnabar);
  border-radius: var(--r);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--ink);
}
.warning form { margin-top: .6rem; }

/* ---- family tree ---- */
ul { padding-left: 0; }
main ul { list-style: none; }
.tree-node {
  margin-left: 1.5rem;
  border-left: 2px solid var(--line);
  padding-left: 1rem;
  margin-top: .5rem;
}

/* ---- card / contact list (mirrors hkgala2026.buddhisttemple.ca's staff
   directory — name + tap-to-call phone on the left, an action pill on the
   right, rows separated by hairlines inside one raised card) ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem 1.4rem;
}
.contact-list { display: flex; flex-direction: column; }
.contact-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.contact-row:last-child { border-bottom: none; }
.contact-row .who { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.contact-row .name { font-family: var(--serif); font-weight: 700; font-size: 1.02rem; color: var(--ink); text-decoration: none; }
.contact-row .name:hover { color: var(--gold-deep); }
.contact-row .meta { font-family: var(--mono); font-size: .76rem; color: var(--ink-soft); }

/* "Stretched link" — tapping anywhere on the row opens the person, via an
   invisible overlay stretched from the name link to the row's full bounds
   (inset:0 sizes against .contact-row, the nearest positioned ancestor).
   The phone link sits above it (z-index) so it keeps its own tap-to-call
   behavior instead of being swallowed by the row-wide navigation. */
.contact-row .name::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.contact-row .phone, .contact-row .btn-ghost {
  position: relative;
  z-index: 2;
}

/* tap-to-call phone link — used inside .contact-row and standalone (e.g. next
   to the editable phone field on the person page) */
.phone { font-family: var(--mono); font-size: .82rem; color: var(--ink-soft); text-decoration: none; }
.phone:hover { color: var(--ink-2); }
label > .phone { display: inline-block; margin-top: .4rem; }

.btn-ghost {
  display: inline-block;
  flex: none;
  font-family: var(--mono);
  font-size: .8rem;
  padding: .5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  text-decoration: none;
  background: transparent;
  white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--ink); }

/* ---- primary call-to-action buttons (dashboard's Add Person / New Family) ---- */
.dashboard-actions { display: flex; flex-wrap: wrap; gap: .85rem; margin: 1.5rem 0; }
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 12rem;
  font-family: var(--mono);
  font-weight: 600;
  font-size: .9rem;
  letter-spacing: .01em;
  padding: .9rem 1.6rem;
  cursor: pointer;
  background: linear-gradient(150deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: var(--paper);
  border: 1px solid var(--gold-deep);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.btn-primary:hover { background: linear-gradient(150deg, var(--gold-deep) 0%, var(--ink-2) 100%); border-color: var(--ink-2); color: var(--paper); }

/* ---- star category pills (mirrors putisi-purchasing's StatusPill) ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  font-family: var(--sans);
  font-size: .72rem;
  letter-spacing: .02em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none; }
.pill--auspicious { color: var(--ink); background: var(--gold-pale); border-color: var(--gold); }
.pill--auspicious::before { background: var(--gold-deep); }
.pill--inauspicious { color: var(--ink); background: var(--card); border-color: var(--cinnabar); }
.pill--inauspicious::before { background: var(--cinnabar); }
.pill--neutral { color: var(--ink); background: var(--paper-2); border-color: var(--line); }
.pill--neutral::before { background: var(--ink-soft); }
