/* =====================================================================
   Reyes & Company - one stylesheet for the whole site.
   Palette is taken from the family shield: navy, crimson, gold, parchment.
   ===================================================================== */

:root {
  --navy: #14245a;
  --navy-deep: #0d1838;
  --navy-soft: #21356f;
  --crimson: #8c1b24;
  --crimson-bright: #a8232e;
  --gold: #c9a227;
  --gold-soft: #e3c765;
  --parchment: #f6f1e7;
  --parchment-deep: #ebe2ce;
  --card: #fffdf8;
  --ink: #23201b;
  --ink-soft: #6b6257;
  --line: #ddd2bb;
  --tree-line: #bfae8b;
  --ok: #2f6a43;
  --warn: #9a6a12;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 36, 90, .06), 0 8px 24px rgba(20, 36, 90, .07);
  --shadow-lg: 0 2px 4px rgba(20, 36, 90, .08), 0 18px 48px rgba(20, 36, 90, .14);
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --font-body: "Lora", Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; }

a { color: var(--crimson); }
a:hover { color: var(--crimson-bright); }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5em; color: var(--navy); }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: .01em; }
h2 { font-size: clamp(1.3rem, 2.6vw, 1.7rem); }
h3 { font-size: 1.12rem; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 720px; }

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

.site-header {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: var(--parchment);
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 40;
}
.header-inner { display: flex; align-items: center; gap: 14px; padding: 10px 20px; }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; margin-right: auto; }
.brand img { width: 38px; height: 46px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-display); font-size: 1.12rem; letter-spacing: .1em; text-transform: uppercase; }
.brand-sub { font-family: var(--font-ui); font-size: .68rem; letter-spacing: .22em; text-transform: uppercase; color: var(--gold-soft); }

.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav a {
  font-family: var(--font-ui); font-size: .85rem; letter-spacing: .04em;
  color: #dfe3ef; text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap;
}
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a[aria-current="page"] { background: rgba(201,162,39,.2); color: #fff; box-shadow: inset 0 -2px 0 var(--gold); }
.nav a.badge-holder { position: relative; padding-right: 26px; }
.nav .pip {
  position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--crimson-bright); color: #fff; border-radius: 9px;
  font-size: .64rem; line-height: 17px; text-align: center; font-family: var(--font-ui);
}

.nav-toggle {
  display: none; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  color: #fff; border-radius: 8px; padding: 8px 11px; font-size: 1rem; cursor: pointer;
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--navy-deep); border-bottom: 3px solid var(--gold); padding: 8px;
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px 14px; font-size: .95rem; }
}

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

.site-footer {
  margin-top: auto;
  background: var(--navy-deep);
  color: #b9c0d6;
  font-family: var(--font-ui);
  font-size: .82rem;
  padding: 26px 0;
  border-top: 3px solid var(--gold);
}
.site-footer a { color: var(--gold-soft); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }

/* ------------------------------ layout ----------------------------- */

main { flex: 1 0 auto; padding: 28px 0 56px; }
.page-head { margin-bottom: 22px; }
.page-head p.lede { color: var(--ink-soft); margin: 0; max-width: 62ch; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-title h2, .card-title h3 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

hr.rule { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ----------------------------- buttons ----------------------------- */

.btn {
  font-family: var(--font-ui); font-size: .9rem; font-weight: 600;
  border: 1px solid transparent; border-radius: 9px; padding: 10px 18px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
  background: var(--crimson); color: #fff; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--crimson-bright); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--navy); }
.btn.secondary:hover { background: var(--navy-soft); }
.btn.ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn.ghost:hover { background: var(--parchment-deep); color: var(--navy); }
.btn.gold { background: var(--gold); color: #3a2c05; }
.btn.gold:hover { background: var(--gold-soft); color: #3a2c05; }
.btn.danger { background: transparent; color: var(--crimson); border-color: #e3b9bd; }
.btn.danger:hover { background: #fbeff0; }
.btn.small { padding: 6px 12px; font-size: .8rem; }
.btn.block { width: 100%; justify-content: center; }

/* ------------------------------ forms ------------------------------ */

label { display: block; font-family: var(--font-ui); font-size: .82rem; font-weight: 600; color: var(--navy); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date],
input[type=datetime-local], input[type=search], input[type=number], select, textarea {
  width: 100%; font-family: var(--font-ui); font-size: .95rem;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.field + .field { margin-top: 14px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: flex; align-items: flex-start; gap: 9px; font-family: var(--font-ui); font-size: .88rem; }
.check input { margin-top: 3px; width: auto; }
.hint { font-family: var(--font-ui); font-size: .78rem; color: var(--ink-soft); margin-top: 5px; }

.notice { border-radius: 9px; padding: 12px 14px; font-family: var(--font-ui); font-size: .88rem; margin-bottom: 14px; }
.notice.error { background: #fbeff0; border: 1px solid #e8c3c7; color: #7d1a22; }
.notice.good { background: #eef6f0; border: 1px solid #bcd9c6; color: #24543a; }
.notice.info { background: #f2f4fb; border: 1px solid #ccd4ec; color: #263c78; }

/* ------------------------------ badges ----------------------------- */

.badge {
  display: inline-block; font-family: var(--font-ui); font-size: .7rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px;
  background: var(--parchment-deep); color: var(--ink-soft);
}
.badge.active  { background: #e4f0e8; color: var(--ok); }
.badge.pending { background: #fbf0d8; color: var(--warn); }
.badge.frozen  { background: #f6dfe1; color: var(--crimson); }
.badge.denied  { background: #eee; color: #666; }
.badge.admin   { background: var(--navy); color: var(--gold-soft); }

/* ------------------------------- hero ------------------------------ */

.hero {
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(201,162,39,.18), transparent 60%),
    linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: var(--parchment);
  padding: 46px 0 52px;
  text-align: center;
  border-bottom: 3px solid var(--gold);
}
.hero h1 { color: #fff; margin-bottom: .2em; }
.hero .shield { width: min(210px, 46vw); filter: drop-shadow(0 10px 28px rgba(0,0,0,.45)); margin-bottom: 18px; }
.hero .tagline { font-size: 1.08rem; color: var(--gold-soft); font-style: italic; margin: 0 auto 22px; max-width: 46ch; }
.hero .hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.section { padding: 40px 0; }
.section.alt { background: var(--parchment-deep); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { text-align: center; margin-bottom: 26px; }
.section-head p { color: var(--ink-soft); max-width: 60ch; margin: 0 auto; }

/* ------------------------------ events ----------------------------- */

.event-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.event-flyer {
  background: var(--parchment-deep); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; min-height: 190px; padding: 14px;
  cursor: pointer; position: relative;
}
.event-flyer canvas, .event-flyer img { max-height: 280px; box-shadow: var(--shadow); border-radius: 4px; background: #fff; }
.event-flyer .flyer-empty { font-family: var(--font-ui); font-size: .85rem; color: var(--ink-soft); text-align: center; }
.event-flyer .zoom-hint {
  position: absolute; bottom: 8px; right: 8px; background: rgba(20,36,90,.85); color: #fff;
  font-family: var(--font-ui); font-size: .7rem; padding: 4px 8px; border-radius: 999px;
}
.event-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.event-when {
  font-family: var(--font-ui); font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--crimson);
}
.event-meta { font-family: var(--font-ui); font-size: .86rem; color: var(--ink-soft); }
.event-actions { margin-top: auto; padding-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.countdown {
  display: inline-block; font-family: var(--font-ui); font-size: .72rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; background: var(--gold); color: #3a2c05;
  border-radius: 999px; padding: 3px 10px;
}

/* ------------------------------ modal ------------------------------ */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(13,24,56,.7); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { width: min(1000px, 100%); }
.modal-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--navy); color: #fff; border-bottom: 3px solid var(--gold);
}
.modal-head h2, .modal-head h3 { color: #fff; margin: 0; font-size: 1.05rem; flex: 1; }
.modal-head button {
  background: rgba(255,255,255,.14); border: 0; color: #fff; width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.modal-body { padding: 18px; overflow: auto; }
.modal-body.flush { padding: 0; background: #56585e; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; }
.pdf-pages canvas { max-width: 100%; box-shadow: var(--shadow-lg); background: #fff; }

/* ---------------------------- directory ---------------------------- */

.search-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.search-bar input[type=search] { flex: 1 1 240px; }
.search-bar select { flex: 0 1 220px; }

.person-card { display: flex; gap: 14px; align-items: flex-start; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none;
  background: var(--navy); color: var(--gold-soft); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.15rem; border: 2px solid var(--gold);
}
.person-card h3 { margin: 0 0 2px; font-size: 1.05rem; }
.person-lines { font-family: var(--font-ui); font-size: .87rem; color: var(--ink-soft); }
.person-lines a { color: var(--navy); text-decoration: none; }
.person-lines a:hover { text-decoration: underline; }
.person-lines div { display: flex; gap: 6px; }
.person-lines .k { color: #9a9081; min-width: 58px; flex: none; }

/* ------------------------------ table ------------------------------ */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: .87rem; }
table.data th, table.data td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-soft); background: var(--parchment-deep); white-space: nowrap; }
table.data tbody tr:hover { background: #fbf7ee; }

/* ------------------------- families / tree ------------------------- */

.branch-tile {
  display: block; text-decoration: none; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; position: relative;
}
.branch-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: inherit; }
.branch-tile.founders { border-color: var(--gold); background: linear-gradient(180deg, #fffaec, var(--card)); }
.branch-tile h3 { margin: 0 0 4px; }
.branch-tile .counts { font-family: var(--font-ui); font-size: .78rem; color: var(--ink-soft); }

.tree-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button {
  font-family: var(--font-ui); font-size: .82rem; padding: 7px 14px; border: 0; background: transparent;
  cursor: pointer; color: var(--ink-soft);
}
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }

.tree-scroll { overflow-x: auto; padding: 6px 0 16px; }

/* classic top-down chart built from nested lists */
.chart, .chart ul { list-style: none; margin: 0; padding: 0; }
.chart { display: flex; justify-content: center; min-width: min-content; }
.chart ul { display: flex; justify-content: center; padding-top: 22px; position: relative; }
.chart li { position: relative; padding: 22px 7px 0; text-align: center; list-style: none; }
.chart li::before, .chart li::after {
  content: ''; position: absolute; top: 0; right: 50%;
  border-top: 2px solid var(--tree-line); width: 50%; height: 22px;
}
.chart li::after { right: auto; left: 50%; border-left: 2px solid var(--tree-line); }
.chart li:only-child { padding-top: 0; }
.chart li:only-child::after, .chart li:only-child::before { display: none; }
.chart li:first-child::before, .chart li:last-child::after { border: 0 none; }
.chart li:last-child::before { border-right: 2px solid var(--tree-line); border-radius: 0 7px 0 0; }
.chart li:first-child::after { border-radius: 7px 0 0 0; }
.chart ul ul::before {
  content: ''; position: absolute; top: 0; left: 50%;
  border-left: 2px solid var(--tree-line); width: 0; height: 22px;
}

.node {
  display: inline-block; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-top: 3px solid var(--navy); border-radius: 10px; padding: 9px 12px; min-width: 150px;
  max-width: 210px; box-shadow: var(--shadow); cursor: pointer; position: relative;
}
.node:hover { border-color: var(--gold); }
.node.root { border-top-color: var(--gold); background: linear-gradient(180deg, #fffaec, var(--card)); }
.node .n-name { font-family: var(--font-display); font-size: .92rem; color: var(--navy); line-height: 1.25; }
.node .n-sub { font-family: var(--font-ui); font-size: .72rem; color: var(--ink-soft); margin-top: 2px; }
.node .n-spouse { font-family: var(--font-ui); font-size: .72rem; color: var(--crimson); margin-top: 2px; }
.node .n-add {
  position: absolute; right: -9px; bottom: -9px; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--gold); background: var(--gold); color: #3a2c05; font-size: .85rem; line-height: 20px;
  text-align: center; cursor: pointer; display: none; font-family: var(--font-ui); padding: 0;
}
.can-edit .node:hover .n-add { display: block; }

/* indented outline view */
.outline, .outline ul { list-style: none; margin: 0; padding: 0; }
.outline ul { margin-left: 16px; padding-left: 16px; border-left: 2px solid var(--tree-line); }
.outline li { padding: 5px 0; position: relative; }
.outline li > .o-row {
  display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; padding: 6px 10px;
  border-radius: 8px; cursor: pointer;
}
.outline li > .o-row:hover { background: #fbf7ee; }
.outline .o-name { font-family: var(--font-display); color: var(--navy); }
.outline .o-meta { font-family: var(--font-ui); font-size: .8rem; color: var(--ink-soft); }
.outline ul li::before {
  content: ''; position: absolute; left: -18px; top: 20px; width: 14px; border-top: 2px solid var(--tree-line);
}

/* ------------------------------ admin ------------------------------ */

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin-bottom: 20px; }
.tabs button {
  font-family: var(--font-ui); font-size: .88rem; font-weight: 600; background: transparent; border: 0;
  padding: 10px 15px; cursor: pointer; color: var(--ink-soft); border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs button[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--crimson); }
.tabs .count { background: var(--crimson); color: #fff; border-radius: 999px; font-size: .68rem; padding: 1px 7px; margin-left: 6px; }

.stat-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-family: var(--font-display); font-size: 1.8rem; color: var(--navy); line-height: 1; }
.stat .l { font-family: var(--font-ui); font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-soft); margin-top: 5px; }

/* ------------------------------ toast ------------------------------ */

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--navy-deep); color: #fff; font-family: var(--font-ui); font-size: .88rem;
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,.14);
  animation: pop .2s ease-out;
}
.toast.bad { background: var(--crimson); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--navy);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); font-family: var(--font-ui); }
.empty .big { font-size: 2rem; margin-bottom: 8px; }

.demo-banner {
  background: var(--gold); color: #3a2c05; font-family: var(--font-ui); font-size: .82rem;
  text-align: center; padding: 8px 16px; border-bottom: 1px solid #a8871c;
}

@media print {
  .site-header, .site-footer, .btn, .tabs, .search-bar, .demo-banner { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
