/* ==========================================================================
   The Playgroup: Magic-themed styling. Light = aged parchment, Dark = vault at night.
   ========================================================================== */

:root {
  --bg: #ece1c9;
  --bg-glow: #f8f0dc;
  --surface: #faf4e4;
  --surface-2: #f0e5c8;
  --ink: #2b2218;
  --muted: #66563f;
  --line: #cbb687;
  --line-soft: #ddcea6;
  --gold: #a8841f;
  --gold-hi: #d1ab34;
  --gold-text: #7a5c0f;
  --gold-btn: #7d5f12;
  --on-gold: #ffffff;
  --title-grad: linear-gradient(180deg, #c99a22 0%, #7a5608 100%);
  --up: #2c6a39;
  --down: #8e2a2a;
  --focus: #1f5fa8;
  --shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 8px 24px rgba(90, 62, 16, .13);
  --kind-suggestion-bg: #dbead3; --kind-suggestion-fg: #234d2b;
  --kind-question-bg: #d6e4f3;   --kind-question-fg: #1e4571;
  --kind-idea-bg: #f3dcd2;       --kind-idea-fg: #7b2d17;
  --danger: #8e2a2a;
  --paper: #f7efd9;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0d14;
  --bg-glow: #1a1f33;
  --surface: #131722;
  --surface-2: #1b2133;
  --ink: #ebe5d3;
  --muted: #a69f8b;
  --line: #3f3823;
  --line-soft: #2a2719;
  --gold: #d4af37;
  --gold-hi: #f1d173;
  --gold-text: #e3c25a;
  --gold-btn: #d4af37;
  --on-gold: #17120a;
  --title-grad: linear-gradient(180deg, #f8e59a 0%, #b88b1c 100%);
  --up: #74d18b;
  --down: #ef8080;
  --focus: #7db3f0;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 10px 30px rgba(0, 0, 0, .5);
  --kind-suggestion-bg: #1c3523; --kind-suggestion-fg: #9fe0b0;
  --kind-question-bg: #1a2e48;   --kind-question-fg: #9cc7f5;
  --kind-idea-bg: #43241b;       --kind-idea-fg: #f2b09a;
  --danger: #ef8080;
  --paper: #10131d;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 50% -8%, var(--bg-glow) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

main { flex: 1; padding-bottom: 3rem; }

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

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold-btn); color: var(--on-gold); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
.narrow { max-width: 820px; }
.muted { color: var(--muted); }
.center { text-align: center; }

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

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--gold-hi) inset;
}

.header-row { display: flex; align-items: center; gap: 1.25rem; min-height: 3.75rem; flex-wrap: wrap; padding-top: .35rem; padding-bottom: .35rem; }

.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); }
.brand-name { font-family: Cinzel, Georgia, serif; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 1.05rem; }

.pips { display: inline-flex; gap: 3px; }
.pip { width: 11px; height: 11px; border-radius: 50%; display: block; box-shadow: 0 0 0 1.5px var(--gold) inset, 0 1px 2px rgba(0, 0, 0, .35); }
.pip.w { background: #f5efcf; }
.pip.u { background: #3f7fc4; }
.pip.b { background: #3a2f45; }
.pip.r { background: #cf4a32; }
.pip.g { background: #3a8a4f; }

.tabs { display: flex; gap: .25rem; margin-left: .5rem; }
.tabs a {
  font-family: Cinzel, Georgia, serif; font-weight: 500; font-size: .92rem; letter-spacing: .06em; text-transform: uppercase;
  text-decoration: none; color: var(--muted); padding: .55rem .9rem; border-bottom: 3px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--gold-text); border-bottom-color: var(--gold-hi); }

.header-tools { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.header-tools form { margin: 0; }
.whoami { color: var(--muted); font-size: 1rem; }
.admin-tag { font-family: Cinzel, serif; font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--gold); color: var(--gold-text); border-radius: 3px; padding: 0 .3rem; margin-left: .2rem; }

.link-btn { background: none; border: 0; padding: .3rem .2rem; font: inherit; color: var(--gold-text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { color: var(--ink); }

.icon-btn { width: 2.4rem; height: 2.4rem; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--gold-text); cursor: pointer; }
.icon-btn:hover { border-color: var(--gold); }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
:root:not([data-theme="dark"]) .i-sun { display: none; }
:root:not([data-theme="dark"]) .i-moon { display: block; }

.site-footer { padding: 1.5rem 0 2rem; text-align: center; opacity: .8; }

/* ---------------------------------------------------------------- generic */

.flash { margin: 1rem 0 0; padding: .7rem 1rem; border: 1px solid var(--gold); border-left-width: 5px; background: var(--surface-2); border-radius: 4px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 1.25rem 1.4rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 2.2rem 0 1rem; flex-wrap: wrap; }
.page-title { font-family: Cinzel, Georgia, serif; font-weight: 700; letter-spacing: .06em; font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 .2rem; color: var(--ink); }
.lede { margin: 0; color: var(--muted); max-width: 46ch; }
.crumb { margin: 1.6rem 0 .5rem; }
.section-title { font-family: Cinzel, Georgia, serif; font-size: 1.1rem; letter-spacing: .08em; text-transform: uppercase; margin: 1.8rem 0 .8rem; color: var(--gold-text); }
.card .section-title { margin-top: 0; }

.btn {
  display: inline-block; font-family: Cinzel, Georgia, serif; font-weight: 500; font-size: .88rem; letter-spacing: .07em; text-transform: uppercase;
  text-decoration: none; text-align: center; cursor: pointer;
  padding: .6rem 1.1rem; border-radius: 5px; border: 1px solid var(--gold); background: transparent; color: var(--gold-text);
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn-primary { background: var(--gold-btn); color: var(--on-gold); border-color: var(--gold-btn); }
.btn-primary:hover { background: var(--gold-btn); color: var(--on-gold); filter: brightness(1.12); }
.btn-small { padding: .3rem .7rem; font-size: .75rem; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; margin-top: 1rem; }

.badge { display: inline-block; font-family: Cinzel, serif; font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; padding: .12rem .55rem; border-radius: 999px; font-weight: 500; }
.badge.kind-suggestion { background: var(--kind-suggestion-bg); color: var(--kind-suggestion-fg); }
.badge.kind-question { background: var(--kind-question-bg); color: var(--kind-question-fg); }
.badge.kind-idea { background: var(--kind-idea-bg); color: var(--kind-idea-fg); }

.up-n { color: var(--up); }
.down-n { color: var(--down); }

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

.form label { display: block; font-family: Cinzel, serif; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 1rem 0 .3rem; }
.form label:first-child, .form > input[type="hidden"] + label { margin-top: 0; }
.form input[type="text"], .form input[type="password"], .form textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 5px; padding: .6rem .75rem;
}
.form textarea { resize: vertical; min-height: 7rem; }
.form input:focus, .form textarea:focus { border-color: var(--gold); outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent); outline-offset: 0; }
.form-actions { margin-top: 1.1rem; display: flex; gap: .6rem; }
.hint { margin: .3rem 0 0; font-size: .95rem; color: var(--muted); }

.kind-pick { border: 0; padding: 0; margin: 0 0 .5rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.kind-pick legend { font-family: Cinzel, serif; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0; margin-bottom: .5rem; }
.pill { margin: 0 !important; position: relative; cursor: pointer; }
.pill input { position: absolute; opacity: 0; inset: 0; }
.pill span { display: inline-block; padding: .35rem .9rem; border-radius: 999px; border: 2px solid var(--line); font-family: Cinzel, serif; font-size: .8rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink); background: var(--paper); }
.pill input:checked + span { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-hi) inset; background: var(--surface-2); }
.pill input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------------------------------------------------------------- forum */

.toolbar { display: flex; gap: .75rem 1.25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); }
.seg a { padding: .35rem .85rem; text-decoration: none; color: var(--muted); font-family: Cinzel, serif; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a:hover { color: var(--ink); background: var(--surface-2); }
.seg a.on { background: var(--gold-btn); color: var(--on-gold); }

.post-list, .comment-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.comment-list { margin-bottom: 1.2rem; }

.post-row, .post-full { display: grid; grid-template-columns: 3.4rem 1fr; gap: 1rem; }
.post-row { scroll-margin-top: 5rem; }
.post-title { font-size: 1.35rem; line-height: 1.25; margin: .35rem 0 .25rem; font-weight: 600; }
.post-title a { color: var(--ink); text-decoration: none; }
.post-title a:hover { color: var(--gold-text); text-decoration: underline; }
.post-heading { font-size: clamp(1.5rem, 4vw, 2rem); line-height: 1.2; margin: .4rem 0 .3rem; font-weight: 600; }
.excerpt { margin: 0 0 .4rem; color: var(--ink); opacity: .88; overflow-wrap: anywhere; }
.post-meta { margin: 0; font-size: .98rem; color: var(--muted); }
.post-meta .tally span { white-space: nowrap; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; margin: .8rem 0 0; }

.votebox { display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.votebox form { margin: 0; }
.score { font-family: Cinzel, serif; font-weight: 700; font-size: 1.15rem; min-width: 2ch; text-align: center; }
.vote { width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.vote:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.vote.up.on { color: var(--up); background: color-mix(in srgb, var(--up) 16%, transparent); border-color: var(--up); }
.vote.down.on { color: var(--down); background: color-mix(in srgb, var(--down) 16%, transparent); border-color: var(--down); }

.actions { display: flex; gap: .5rem; margin-top: 1rem; }
.actions form { margin: 0; }

.voters { margin-top: 1rem; }
.voter-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.voter-cols h3 { margin: 0 0 .4rem; font-family: Cinzel, serif; font-size: .9rem; letter-spacing: .06em; text-transform: uppercase; }
.voter-cols p { margin: 0; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.chips li { padding: .1rem .65rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); font-size: 1rem; }

.comment { scroll-margin-top: 5rem; padding: 1rem 1.2rem; }
.comment:target { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-hi); }
.comment .prose { margin-top: .4rem; }

.empty { text-align: center; padding: 2.5rem 1.5rem; }
.empty p { margin-top: 0; }

/* ---------------------------------------------------------------- auth */

.auth-wrap { min-height: 70vh; display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 410px; padding: 2rem 1.9rem; border-top: 4px solid var(--gold-hi); }
.auth-card .crown { display: block; margin: 0 auto .4rem; color: var(--gold); }
.auth-title { margin: 0 0 .2rem; text-align: center; font-family: Cinzel, serif; font-size: 1.55rem; letter-spacing: .08em; text-transform: uppercase; }
.auth-card .muted { margin: 0 0 1.4rem; }
.auth-switch { text-align: center; margin: 1.3rem 0 0; }

/* ---------------------------------------------------------------- Rule 0 */

.decree { width: 100%; max-width: 820px; margin: 2.4rem auto 1rem; padding: 0 1rem; }

.decree-inner {
  position: relative;
  padding: clamp(2rem, 6vw, 3.75rem) clamp(1.4rem, 6vw, 4rem) clamp(1.8rem, 5vw, 3rem);
  background:
    radial-gradient(900px 400px at 50% 0%, color-mix(in srgb, var(--gold-hi) 14%, transparent), transparent 70%),
    var(--paper);
  border: 2px solid var(--gold);
  outline: 1px solid var(--gold-hi);
  outline-offset: 7px;
  box-shadow: var(--shadow), 0 0 0 7px var(--bg), 0 0 60px color-mix(in srgb, var(--gold-hi) 16%, transparent);
}
.decree-inner::before {
  content: ""; position: absolute; inset: 9px; border: 1px solid var(--line); pointer-events: none;
}

.corner { position: absolute; width: 34px; height: 34px; border: 3px solid var(--gold); pointer-events: none; }
.corner::after { content: ""; position: absolute; width: 9px; height: 9px; background: var(--gold-hi); transform: rotate(45deg); }
.corner.tl { top: 15px; left: 15px; border-right: 0; border-bottom: 0; }
.corner.tl::after { top: -6px; left: -6px; }
.corner.tr { top: 15px; right: 15px; border-left: 0; border-bottom: 0; }
.corner.tr::after { top: -6px; right: -6px; }
.corner.bl { bottom: 15px; left: 15px; border-right: 0; border-top: 0; }
.corner.bl::after { bottom: -6px; left: -6px; }
.corner.br { bottom: 15px; right: 15px; border-left: 0; border-top: 0; }
.corner.br::after { bottom: -6px; right: -6px; }

.decree-head { text-align: center; }
.crown { color: var(--gold); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .25)); }
.decree-title {
  margin: .35rem 0 .1rem;
  font-family: "Cinzel Decorative", Cinzel, Georgia, serif; font-weight: 700;
  font-size: clamp(2.9rem, 10vw, 4.8rem); line-height: 1.05; letter-spacing: .1em; text-transform: uppercase;
  background: var(--title-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--gold);
  filter: drop-shadow(0 2px 0 color-mix(in srgb, var(--bg) 60%, transparent));
}
.decree-sub { margin: 0; font-style: italic; font-size: 1.2rem; color: var(--muted); letter-spacing: .02em; }

.flourish { display: flex; align-items: center; gap: .8rem; margin: 1.6rem auto; max-width: 420px; }
.flourish span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.flourish i { width: 11px; height: 11px; transform: rotate(45deg); background: var(--gold-hi); box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--gold); }

.decree-body { font-size: 1.28rem; line-height: 1.75; }
.decree-body > p:first-child::first-letter {
  float: left; font-family: "Cinzel Decorative", Cinzel, serif; font-weight: 700;
  font-size: 4.1rem; line-height: .82; padding: .32rem .55rem 0 0; color: var(--gold-text);
}
.decree-body p { margin: 0 0 1.1rem; }
.decree-body h1, .decree-body h2, .decree-body h3 {
  font-family: Cinzel, Georgia, serif; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  text-align: center; color: var(--gold-text); margin: 2.2rem 0 1.2rem; line-height: 1.3;
}
.decree-body h1 { font-size: 1.6rem; }
.decree-body h2 { font-size: 1.2rem; }
.decree-body h3 { font-size: 1rem; }
.decree-body h2::after, .decree-body h1::after {
  content: ""; display: block; width: 90px; height: 2px; margin: .7rem auto 0;
  background: linear-gradient(90deg, transparent, var(--gold-hi), transparent);
}
.decree-body strong { font-weight: 600; color: var(--ink); }
.decree-body blockquote {
  margin: 1.4rem 0; padding: .5rem 1.4rem; font-style: italic; text-align: center;
  border-left: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--gold-hi) 8%, transparent);
}
.decree-body blockquote p { margin: .4rem 0; }
.decree-body code { font-size: .9em; background: var(--surface-2); padding: .05rem .35rem; border-radius: 3px; border: 1px solid var(--line-soft); }
.decree-body hr { border: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); margin: 2rem 0; }
.decree-body a { color: var(--gold-text); }

.decree-body > ol { list-style: none; padding: 0; margin: 0 0 1.2rem; counter-reset: article; }
.decree-body > ol > li { counter-increment: article; position: relative; padding: .15rem 0 .15rem 3.6rem; margin-bottom: .9rem; }
.decree-body > ol > li::before {
  content: "0." counter(article); position: absolute; left: 0; top: .35rem;
  font-family: Cinzel, serif; font-weight: 700; font-size: .95rem; letter-spacing: .05em; color: var(--gold-text);
  border: 1px solid var(--gold); border-radius: 4px; padding: 0 .4rem; background: var(--surface-2); line-height: 1.7;
}
.decree-body > ul { padding-left: 1.4rem; }
.decree-body > ul li::marker { color: var(--gold); }

.decree-foot { text-align: center; }
.decree-foot .flourish { margin-top: 2rem; margin-bottom: .8rem; }
.decree-foot p { margin: 0; font-family: Cinzel, serif; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 640px) {
  body { font-size: 1.08rem; }
  .header-row { gap: .4rem .8rem; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .tabs a { flex: 1; text-align: center; padding: .5rem .4rem; }
  .whoami { display: none; }
  .post-row, .post-full { grid-template-columns: 2.9rem 1fr; gap: .7rem; padding: 1rem .9rem; }
  .voter-cols { grid-template-columns: 1fr; }
  .page-head .btn { width: 100%; }
  .decree-body > ol > li { padding-left: 3.3rem; }
  .corner { width: 24px; height: 24px; }
  .decree-body > p:first-child::first-letter { font-size: 3.4rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .vote, .seg a, .tabs a { transition: background-color .15s, color .15s, border-color .15s, filter .15s; }
}
