/* Anytime Advent. The app's own pages use light and dark themes from the same tokens; a calendar is drawn in its own theme
   (includes/themes.php) in both. Every text colour meets WCAG 2.2 AA on its background. */
:root {
  --bg: #f7f3ec; --card: #ffffff; --ink: #1f2328; --muted: #565d66; --line: #e0d9cc;
  --brand: #8b1e2b; --brand-ink: #ffffff; --link: #8b1e2b; --head: #7c1d26; --head-ink: #ffffff; --head-soft: #f8dfb3;
  --danger: #b42318; --danger-ink: #ffffff; --focus: #b45309;
  --ok-bg: #e2f3eb; --ok-ink: #12482f; --warn-bg: #fff3d4; --warn-ink: #5e4100; --err-bg: #fde8e6; --err-ink: #8a1c12;
  --tag-bg: #efe9dd; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141113; --card: #1e1a1c; --ink: #ece6e2; --muted: #b3aaa6; --line: #3a3235;
    --brand: #f2a0a6; --brand-ink: #2a0a0e; --link: #f6b8bc; --head: #3a1016; --head-ink: #ffffff; --head-soft: #f8dfb3;
    --danger: #ff8f80; --danger-ink: #2a0905; --focus: #fbbf24;
    --ok-bg: #143a2b; --ok-ink: #c4f0dc; --warn-bg: #3a2e0c; --warn-ink: #ffe3a3; --err-bg: #3d1611; --err-ink: #ffd2cb;
    --tag-bg: #2e2729;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--link); text-underline-offset: 2px; }
img { max-width: 100%; height: auto; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.25rem; line-height: 1.25; margin: 1.2rem 0 .6rem; }
.card > h2:first-child, .card > h1:first-child { margin-top: 0; }
p { margin: 0 0 .8rem; }
:is(a, button, input, select, textarea, summary, label.btn, [tabindex]):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--card); color: var(--ink); padding: 8px 12px; z-index: 2000; }
.skip:focus { left: 8px; top: 8px; }
.visually-hidden, .sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 16px; }
main:focus { outline: none; }

/* Header */
.site-header { background: var(--head); color: var(--head-ink); }
.site-header .bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { color: var(--head-ink); text-decoration: none; font-weight: 800; font-size: 1.2rem; padding: 8px 0; }
.brand span, .hero h1 span { margin-right: .3em; }
.nav-out { color: var(--head-soft); padding: 8px 0; }
.site-header .btn.small { background: var(--head-ink); color: var(--head); }
.menu { border-top: 1px solid rgba(255,255,255,.12); }
.menu-row { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.menu a { color: var(--head-soft); text-decoration: none; padding: 10px 0; display: inline-block; border-bottom: 3px solid transparent; min-height: 24px; }
.menu a:hover { color: var(--head-ink); }
.menu a.active { color: var(--head-ink); border-bottom-color: var(--head-soft); font-weight: 600; }

/* Blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; }
.card.narrow { max-width: 560px; margin: 24px auto; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.grid.two.tight { grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.wrap-row { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.hint { color: var(--muted); font-size: .9rem; margin: .3rem 0 .6rem; }
.center { text-align: center; }
.plain { list-style: none; padding: 0; margin: 0 0 1rem; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); justify-content: space-between; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--tag-bg); color: var(--muted); vertical-align: middle; }
.tag.ok { background: var(--ok-bg); color: var(--ok-ink); }
.kicker { text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; font-weight: 700; color: var(--muted); margin: 0 0 .2rem; }

/* Alerts */
.alert, .flash { padding: 12px 14px; border-radius: 8px; margin: 0 0 14px; }
.alert.ok, .flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); }
.alert.error, .flash.error { background: var(--err-bg); color: var(--err-ink); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: var(--brand-ink); border: 2px solid var(--brand);
  border-radius: 10px; padding: 9px 16px; min-height: 44px; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; color: var(--link); }
.btn.big { font-size: 1.1rem; padding: 12px 22px; min-height: 52px; }
.btn.small { min-height: 34px; padding: 5px 12px; font-size: .92rem; }
.btn.wide { width: 100%; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.linkish { background: none; border: 0; padding: 4px 0; min-height: 24px; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; }
.linkish.danger { color: var(--danger); }
form { margin: 0; }

/* Forms */
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 750; font-size: 1.1rem; margin-bottom: 8px; padding: 0; }
.field { margin: 0 0 14px; }
.field > label, .field > .label { display: block; font-weight: 650; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=url], input[type=date], input[type=number], input[type=file], select, textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--muted);
  border-radius: 8px; background: var(--card); color: var(--ink); }
input[type=file] { padding: 8px; }
textarea { resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; margin: 0 0 8px; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--brand); }
.check.sub { margin-left: 30px; font-weight: 500; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }


h1, h2.serif, .advent-title, .box-title, .hero h1 { font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif; }
.cols { display: grid; gap: 0 16px; }
.cols.two { grid-template-columns: 1fr; }
@media (min-width: 640px) { .cols.two { grid-template-columns: 1fr 1fr; } }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.crumbs { margin: 0 0 10px; }
.h-sub { font-size: 1rem; font-weight: 500; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }

/* Home */
.hero { padding: 16px 0 8px; }
.hero h1 { font-size: 2.4rem; }
.lead { font-size: 1.25rem; font-weight: 600; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 8px; }
.steps { padding-left: 1.3rem; margin: 0 0 1rem; }
.steps li { margin-bottom: .6rem; }
.features { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.features li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.features h3 { margin: 0 0 4px; font-size: 1.05rem; }
.features p { margin: 0; }
.faq dt { font-weight: 700; margin-top: 12px; }
.faq dd { margin: 2px 0 6px; }
.demo-card .advent { margin: 12px 0 8px; }
.demo-more { text-align: center; margin: 6px 0 0; }
.theme-gallery { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.theme-gallery li { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }

/* Theme swatches and choosing one */
.swatch { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 7px; border-radius: 8px; }
.swatch span { aspect-ratio: 1; border-radius: 4px; display: flex; align-items: center; justify-content: center; font: 700 .9rem/1 Georgia, serif; }
.theme-pick { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.theme-opt { position: relative; display: flex; flex-direction: column; gap: 6px; border: 2px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; font-weight: 600; }
.theme-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme-opt:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.theme-opt:has(input:checked) > span:last-child::after { content: ' ✓'; }
.theme-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Your calendars */
.cal-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.cal-card { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none; }
.cal-card:hover strong { text-decoration: underline; }
.cal-card .swatch { width: 104px; flex: 0 0 104px; }
.cal-card > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.cal-card strong { font-size: 1.1rem; }
.meta { color: var(--muted); font-size: .9rem; }

/* A calendar's boxes, to fill */
.box-tiles { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.box-tile { display: flex; flex-direction: column; gap: 2px; min-height: 104px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; background: var(--card); }
.box-tile:hover { border-color: var(--brand); }
.box-tile.empty { border-style: dashed; background: transparent; }
.bt-day { font: 700 1.5rem/1 Georgia, serif; }
.bt-date, .bt-ph { font-size: .82rem; color: var(--muted); }
.bt-what { font-size: .92rem; overflow-wrap: anywhere; }
.box-tile.empty .bt-what { color: var(--muted); font-style: italic; }
.photo-edit { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 12px; }
.photo-edit li { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.photo-edit img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; flex: none; }
.photo-edit .field { flex: 1 1 220px; margin: 0; }
.photo-prev { max-width: 220px; border-radius: 10px; display: block; margin: 0 0 6px; }
.link-row .field { margin-bottom: 8px; }
.box-nav { justify-content: space-between; margin: 0 0 16px; }
td.actions form { display: inline; margin-right: 10px; }

/* ── The calendar ─────────────────────────────────────────────────────────── */
.advent { background: var(--t-pattern), linear-gradient(var(--t-bg), var(--t-bg2)); color: var(--t-ink); border-radius: 18px; padding: 20px 16px 18px; margin: 0 0 16px; }
.advent.has-bg { background: linear-gradient(color-mix(in srgb, var(--t-bg) 45%, transparent), color-mix(in srgb, var(--t-bg2) 60%, transparent)), var(--t-photo) center / cover no-repeat, var(--t-bg); }
.advent.has-bg .advent-head { background: color-mix(in srgb, var(--t-bg) 94%, transparent); border-radius: 14px; padding: 14px 16px; }
.advent-head { text-align: center; max-width: 680px; margin: 0 auto 16px; }
.advent-cover { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; margin: 0 0 12px; display: block; }
.advent-from { margin: 0 0 2px; color: var(--t-soft); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .82rem; }
.advent-title { color: var(--t-ink); font-size: 2.3rem; line-height: 1.1; margin: 0 0 6px; }
.advent-status { color: var(--t-soft); font-weight: 700; margin: 0 0 10px; }
.advent-count { font-weight: 500; }
.advent-msg { color: var(--t-ink); margin: 0 auto 8px; max-width: 60ch; }
.advent .btn { background: var(--t-ink); color: var(--t-bg); border-color: var(--t-ink); }
.advent .btn:focus-visible, .advent a:focus-visible { outline-color: var(--t-today); }
.doors { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); grid-auto-flow: dense; }
.doors.few { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); max-width: 520px; margin: 0 auto; }
.doors.mini { grid-template-columns: repeat(4, 1fr); max-width: 300px; margin: 12px auto 0; }
.door-cell { aspect-ratio: 1; }
.door-cell.big { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; }
.door { position: relative; display: block; width: 100%; height: 100%; border-radius: 10px; text-decoration: none; perspective: 700px; color: var(--d-ink); }
.door-inside { position: absolute; inset: 0; border-radius: 10px; background: var(--t-inside); color: var(--t-inside-ink); display: flex; align-items: center; justify-content: center; gap: 4px;
  box-shadow: inset 0 3px 10px rgba(0,0,0,.28); font: 700 1.3rem/1 Georgia, serif; }
.door-inside .in-num { font-size: 1rem; opacity: .9; }
.door.is-open .door-inside::after { content: '✓'; }
.door-front { position: absolute; inset: 0; border-radius: 10px; background: var(--d-bg); color: var(--d-ink); display: flex; flex-direction: column; align-items: center; justify-content: center;
  transform-origin: left center; backface-visibility: hidden; box-shadow: 0 2px 0 rgba(0,0,0,.22), inset 0 0 0 2px rgba(255,255,255,.2), inset 0 0 0 4px rgba(0,0,0,.06); }
.door-num { font: 700 2rem/1 Georgia, 'Times New Roman', serif; }
.big .door-num { font-size: 3.6rem; }
.door-note { font-size: .74rem; font-weight: 700; margin-top: 5px; letter-spacing: .03em; }
.door.is-open .door-front { transform: rotateY(-74deg); }
.door.is-ready:not(.is-open):hover .door-front { transform: rotateY(-14deg); }
.door.opening .door-front { transform: rotateY(-104deg); }
.door.is-today .door-front { box-shadow: 0 0 0 3px var(--t-today), 0 0 16px 2px var(--t-today); }
.door:focus-visible { outline: 3px solid var(--t-today); outline-offset: 3px; }
.door.is-locked { cursor: default; }
.door.shake .door-front { animation: ad-shake .4s; }
@keyframes ad-shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
@media (prefers-reduced-motion: no-preference) {
  .door-front { transition: transform .7s cubic-bezier(.2, .7, .2, 1); }
  .door.is-today:not(.is-open) .door-front { animation: ad-glow 2.4s ease-in-out infinite; }
  @keyframes ad-glow { 50% { box-shadow: 0 0 0 3px var(--t-today), 0 0 26px 6px var(--t-today); } }
}
@media (max-width: 420px) { .doors { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; } .door-num { font-size: 1.6rem; } .big .door-num { font-size: 3rem; } .advent-title { font-size: 1.9rem; } }

/* A box, opened */
.box-dialog { border: 0; padding: 0; border-radius: 18px; width: min(680px, 94vw); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.box-dialog::backdrop { background: rgba(10,8,9,.6); }
.advent.box-dialog-inner { background: var(--t-inside); color: var(--t-inside-ink); border-radius: 0; margin: 0; padding: 22px 22px 18px; position: relative; }
.box-close { position: absolute; top: 8px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 2rem; line-height: 1; cursor: pointer; }
.box-close:focus-visible { outline: 3px solid currentColor; }
.box-day { font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 4px; opacity: .85; }
.box-title { font-size: 1.8rem; line-height: 1.15; margin: 0 0 12px; padding-right: 40px; }
.box-content p { overflow-wrap: anywhere; }
.box-photos { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 0 0 14px; }
.box-photos img { width: 100%; height: auto; border-radius: 10px; display: block; }
.box-photos a:only-child img { max-height: 60vh; object-fit: contain; }
.box-links { display: flex; flex-wrap: wrap; gap: 10px; }
.box-dialog .btn { background: var(--t-btn); color: var(--t-btn-ink); border-color: var(--t-btn); }
.invite .invite-board { margin: 0 0 16px; }
.make-own { text-align: center; }

.site-footer { margin-top: 24px; color: var(--ink); }   /* the shared footer fades its own text */
.site-footer a { color: var(--ink); }
.table-wrap { overflow-x: auto; margin: 12px 0 0; border-radius: 6px; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Cards that open and close (app.js) */
.card-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 24px; margin: 0; padding: 0; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; line-height: inherit; text-align: left; cursor: pointer; }
.card-toggle::after { content: ''; flex: none; margin-left: auto; margin-right: 4px; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); opacity: .75; }
.card-toggle[aria-expanded="false"]::after { transform: rotate(-45deg); }
.card-toggle:hover { color: var(--link); }
.card.collapsed > h1, .card.collapsed > h2 { margin-bottom: 0; }
@media (prefers-reduced-motion: no-preference) { .card-toggle::after { transition: transform .15s; } }
@media print { .site-header, .site-footer, .btn { display: none !important; } body { background: #fff; } .card { border: 0; } .card-body[hidden] { display: block !important; } .card-toggle::after { display: none; } }
