/* ==========================================================================
   ConfessX — front-end styles
   Themes are driven by CSS variables on <html data-theme="...">.
   Override --accent from Admin → Settings → Appearance.
   ========================================================================== */

:root,
[data-theme="midnight"] {
  --bg: #181818;
  --pattern: url("../img/pattern-light.svg");
  --topbar: #232323;
  --topbar-border: rgba(255,255,255,.05);
  --card: rgba(14,14,14,.62);
  --card-hover: rgba(14,14,14,.72);
  --card-border: rgba(255,255,255,.07);
  --text: #d6cdab;
  --heading: #f3f1ea;
  --muted: #8b8b86;
  --icon: #8f8f8f;
  --accent: #d6c58f;
  --accent-text: #161616;
  --input: rgba(10,10,10,.55);
  --input-border: rgba(255,255,255,.09);
  --button: #2c2c2c;
  --button-hover: #383838;
  --comment: rgba(40,40,40,.72);
  --comment-foot: rgba(28,28,28,.85);
  --like: #8fc46a;
  --dislike: #d9675b;
  --glow: rgba(240,235,215,.55);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

[data-theme="crimson"] {
  --bg: #170b0d;
  --topbar: #1e0f12;
  --card: rgba(20,6,9,.66);
  --card-hover: rgba(24,8,11,.76);
  --card-border: rgba(255,120,130,.09);
  --text: #e5d2cf;
  --heading: #fff2ef;
  --muted: #9a7f7f;
  --icon: #a08585;
  --accent: #e0485a;
  --accent-text: #fff;
  --button: #33161b;
  --button-hover: #452027;
  --comment: rgba(48,20,24,.72);
  --comment-foot: rgba(32,12,15,.85);
  --glow: rgba(255,90,110,.55);
}

[data-theme="ocean"] {
  --bg: #0b1418;
  --topbar: #0f1c21;
  --card: rgba(5,14,18,.66);
  --card-hover: rgba(6,18,22,.76);
  --card-border: rgba(120,220,255,.08);
  --text: #cfe3e6;
  --heading: #eefcff;
  --muted: #7d979c;
  --icon: #7f9ca2;
  --accent: #46c2d4;
  --accent-text: #052025;
  --button: #13282f;
  --button-hover: #1b3640;
  --comment: rgba(18,40,48,.72);
  --comment-foot: rgba(10,26,31,.85);
  --glow: rgba(90,220,240,.5);
}

[data-theme="paper"] {
  --bg: #efe8da;
  --pattern: url("../img/pattern-dark.svg");
  --topbar: #2b2622;
  --topbar-border: rgba(0,0,0,.2);
  --card: rgba(255,252,245,.88);
  --card-hover: rgba(255,253,248,.95);
  --card-border: rgba(60,40,20,.12);
  --text: #3a332b;
  --heading: #2a241d;
  --muted: #887d70;
  --icon: #9b8f80;
  --accent: #8a5a2b;
  --accent-text: #fff;
  --input: #fffdf8;
  --input-border: rgba(60,40,20,.2);
  --button: #3a332b;
  --button-hover: #4d443a;
  --comment: rgba(250,245,234,.95);
  --comment-foot: rgba(236,228,212,.95);
  --glow: rgba(255,240,210,.5);
  --shadow: 0 8px 24px rgba(60,40,20,.12);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--text);
  font: 16px/1.55 "Ubuntu", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.has-pattern { background-image: var(--pattern); background-size: 132px 132px; background-attachment: fixed; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
.icon { width: 1em; height: 1em; fill: currentColor; flex: none; }
.sr-only, .hp {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-text); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--topbar);
  border-bottom: 1px solid var(--topbar-border);
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center;
  min-height: 70px;
  padding: 0 16px;
}
.nav-left { display: flex; align-items: center; gap: 22px; min-width: 0; }
.brand { color: #f2f2f2; font-size: 1.22rem; font-weight: 500; white-space: nowrap; }
.nav-links { display: flex; gap: 16px; }
.nav-links a { color: #9a9a9a; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-links a.active { color: #fff; }
.brand:hover { text-decoration: none; }
.logo { display: block; text-align: center; line-height: 1; }
.logo:hover { text-decoration: none; }
.logo img { max-height: 56px; width: auto; display: block; margin: 0 auto; }
.logo-text {
  font-family: "Cinzel Decorative", "Cinzel", Georgia, serif;
  font-size: 1.85rem;
  letter-spacing: .04em;
  color: #e9e6dc;
  text-transform: lowercase;
  text-shadow: 0 0 6px var(--glow), 0 0 18px var(--glow), 0 2px 0 rgba(0,0,0,.6);
  white-space: nowrap;
}
.logo-text .paren { font-family: Georgia, serif; font-size: 2.35rem; font-weight: 300; padding: 0 .08em; vertical-align: -.06em; }
.nav-right { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.nav-toggle { display: none; background: none; border: 0; color: #ddd; font-size: 1.5rem; padding: 6px; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 3px;
  background: var(--button);
  color: #eee;
  font: inherit;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--button-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: rgba(255,255,255,.04); color: #b9b9b9; }
.btn-ghost:hover { color: #fff; }
.btn-primary { background: var(--button); color: #f5f5f5; box-shadow: 0 2px 6px rgba(0,0,0,.35); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 572px; margin: 0 auto; padding: 0 16px; }
main.container { flex: 1; padding-top: 28px; padding-bottom: 40px; }
.page-title {
  text-align: center; color: var(--heading); font-weight: 500;
  font-size: 2rem; margin: 0 0 20px; letter-spacing: .01em;
  word-break: break-word;
}

/* ---------- Toolbar (tabs + search) ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--card-border); padding: 4px; border-radius: 4px; }
.tabs a { color: var(--muted); padding: 5px 11px; border-radius: 3px; font-size: .9rem; }
.tabs a:hover { color: var(--heading); text-decoration: none; }
.tabs a.active { background: var(--button-hover); color: var(--heading); }
.search { display: flex; background: var(--input); border: 1px solid var(--input-border); border-radius: 4px; overflow: hidden; }
.search input { background: transparent; border: 0; color: var(--text); padding: 7px 10px; font: inherit; font-size: .9rem; width: 170px; }
.search input:focus { outline: none; }
.search button { background: none; border: 0; color: var(--icon); padding: 0 10px; cursor: pointer; font-size: 1rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 3px;
  padding: 24px 28px 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.02);
  backdrop-filter: blur(1px);
  transition: background .2s;
}
.card:hover { background: var(--card-hover); }
.cid { color: var(--muted); font-size: .98rem; }
.cid:hover { color: var(--heading); text-decoration: none; }
.badge { display: inline-block; margin-left: 6px; font-size: .72rem; padding: 2px 7px; border-radius: 10px; background: var(--accent); color: var(--accent-text); vertical-align: 2px; }
.confession .body { font-size: 1.12rem; margin: 6px 0 16px; overflow-wrap: anywhere; }
.confession .body p { margin: 0; }
.read-more { display: inline-block; margin: -6px 0 14px; font-size: .9rem; }
.meta { display: flex; align-items: flex-start; gap: 8px; }
.meta time { font-size: .76rem; color: var(--muted); padding-top: 8px; white-space: nowrap; }
.sep { width: 2px; height: 20px; background: var(--text); opacity: .75; margin-top: 4px; }
.actions { display: flex; gap: 4px; }
.vote {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 2px 5px; cursor: pointer;
  color: var(--icon); font: inherit; min-width: 34px;
}
.vote .icon { width: 28px; height: 28px; transition: transform .15s, color .15s; }
.vote .n { font-size: .78rem; color: var(--text); opacity: .85; }
.vote:hover { text-decoration: none; }
.vote:hover .icon { color: var(--heading); transform: translateY(-1px); }
.vote[data-value="1"].is-active .icon { color: var(--like); }
.vote[data-value="-1"].is-active .icon { color: var(--dislike); }
.vote.pop .icon { animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.25); } }

.card-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.share { display: flex; gap: 6px; flex-wrap: wrap; }
.share-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: .76rem; font-weight: 500;
  padding: 4px 9px; border-radius: 3px; border: 0; cursor: pointer;
  color: #fff; background: #555;
}
.share-btn:hover { text-decoration: none; filter: brightness(1.12); }
.share-btn .icon { width: 13px; height: 13px; }
.share-btn.fb { background: #4267b2; }
.share-btn.x { background: #111; border: 1px solid #333; }
.share-btn.wa { background: #1fa855; }
.report { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; color: var(--muted); font: inherit; font-size: .78rem; cursor: pointer; padding: 4px; }
.report:hover { color: var(--dislike); }
.report.done { color: var(--dislike); pointer-events: none; }

/* ---------- YouTube lite embed ---------- */
.yt { position: relative; margin-top: 14px; aspect-ratio: 16/9; background: #000; overflow: hidden; border-radius: 2px; cursor: pointer; }
.yt img, .yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.yt img { opacity: .85; transition: opacity .2s; color: transparent; font-size: 0; }
.yt:hover img { opacity: 1; }
.yt-play {
  position: absolute; left: 50%; top: 50%; width: 68px; height: 48px; transform: translate(-50%,-50%);
  border: 0; border-radius: 12px; background: rgba(20,20,20,.82); cursor: pointer;
}
.yt-play::after { content: ""; position: absolute; left: 27px; top: 14px; border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #fff; }
.yt:hover .yt-play { background: #e00; }

/* ---------- Prev / next ---------- */
.prev-next { display: flex; justify-content: space-between; font-size: .88rem; margin: -6px 2px 14px; }
.prev-next a { color: var(--muted); }
.prev-next a:hover { color: var(--heading); }

/* ---------- Comments ---------- */
.comment-list { margin-bottom: 22px; }
.no-comments { text-align: center; color: var(--muted); font-size: .92rem; margin: 6px 0 18px; }
.comment { background: var(--comment); border: 1px solid var(--card-border); margin: 0 4px 3px; }
.comment-top { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px 8px 10px; }
.comment-body { color: var(--accent); font-weight: 500; letter-spacing: .03em; font-size: .92rem; overflow-wrap: anywhere; }
.comment-body p { margin: 0; }
.comment time { font-size: .74rem; color: var(--muted); white-space: nowrap; letter-spacing: .04em; }
.comment-bottom { display: flex; justify-content: space-between; align-items: center; padding: 3px 8px 4px; background: var(--comment-foot); }
.author { font-size: .78rem; font-style: italic; color: var(--text); }
.comment-actions { display: flex; align-items: center; gap: 2px; }
.cvote { background: none; border: 0; padding: 2px; color: var(--icon); cursor: pointer; display: inline-flex; }
.cvote .icon { width: 16px; height: 16px; }
.cvote:hover { color: var(--heading); }
.cvote[data-value="1"].is-active { color: var(--like); }
.cvote[data-value="-1"].is-active { color: var(--dislike); }
.score { font-size: .76rem; min-width: 14px; text-align: right; margin-left: 2px; }
.report-sm { opacity: 0; transition: opacity .15s; }
.comment:hover .report-sm, .report-sm:focus-visible { opacity: 1; }
.report-sm .icon { width: 13px; height: 13px; }

/* ---------- Forms ---------- */
.post-form { max-width: 420px; margin: 0 auto; text-align: center; }
.comment-form { margin-top: 18px; }
.editor { position: relative; }
.post-form textarea, .name-input {
  display: block; width: 100%;
  background: var(--input) linear-gradient(180deg, rgba(255,255,255,.015), transparent);
  border: 1px solid var(--input-border);
  color: var(--text);
  font: 1.05rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 10px 9px;
  border-radius: 1px;
}
.post-form textarea { min-height: 152px; resize: vertical; }
.post-form textarea::placeholder, .name-input::placeholder { color: var(--muted); opacity: .8; }
.post-form textarea:focus, .name-input:focus { outline: none; border-color: var(--accent); }
.name-input { margin-bottom: 8px; font-size: .95rem; }
.editor-bar { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 6px 0 22px; position: relative; }
.counter { color: var(--heading); font-size: .98rem; }
.counter.low { color: var(--dislike); }
.emoji-toggle { position: absolute; left: 0; top: -2px; background: none; border: 0; color: var(--icon); font-size: 1.3rem; padding: 2px; cursor: pointer; }
.emoji-toggle:hover { color: var(--heading); }
.emoji-panel {
  position: absolute; left: 0; top: 30px; z-index: 10;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  background: var(--topbar); border: 1px solid var(--card-border); padding: 6px; border-radius: 4px;
  box-shadow: var(--shadow);
}
.emoji-panel button { background: none; border: 0; font-size: 1.25rem; padding: 4px; cursor: pointer; border-radius: 3px; line-height: 1; }
.emoji-panel button:hover { background: rgba(255,255,255,.08); }
.rules { text-align: left; font-size: .85rem; color: var(--muted); border-left: 2px solid var(--accent); padding: 4px 10px; margin: -8px 0 14px; }
.hint { font-size: .78rem; color: var(--muted); margin: -10px 0 16px; }

/* ---------- Alerts, empty, ads, pagination ---------- */
.alert { padding: 10px 14px; border-radius: 3px; margin: 0 0 16px; font-size: .94rem; text-align: center; border: 1px solid transparent; }
.alert-success { background: rgba(110,170,90,.16); border-color: rgba(110,170,90,.35); color: #bfe3a8; }
.alert-info { background: rgba(120,160,200,.14); border-color: rgba(120,160,200,.35); color: #bcd5ec; }
.alert-error { background: rgba(210,90,80,.15); border-color: rgba(210,90,80,.4); color: #f2b4ad; }
[data-theme="paper"] .alert-success { color: #335d22; }
[data-theme="paper"] .alert-info { color: #24486b; }
[data-theme="paper"] .alert-error { color: #8b2a20; }
.empty { text-align: center; }
.empty p { margin-top: 0; }
.ad { margin: 0 0 20px; text-align: center; overflow: hidden; }
.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin: 6px 0 10px; }
.pagination a, .pagination span {
  min-width: 36px; padding: 6px 10px; text-align: center; border-radius: 3px;
  background: var(--card); border: 1px solid var(--card-border); color: var(--text); font-size: .9rem;
}
.pagination a:hover { background: var(--button-hover); text-decoration: none; }
.pagination .current { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.pagination .gap { background: none; border: 0; }

/* ---------- Footer & toast ---------- */
.site-footer { background: var(--topbar); border-top: 1px solid var(--topbar-border); padding: 18px 0; text-align: center; font-size: .85rem; color: #aaa; }
.site-footer p { margin: 4px 0; }
.site-footer a { color: #ccc; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #111; color: #eee; border: 1px solid #333; padding: 10px 16px; border-radius: 4px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; font-size: .92rem;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .topbar-inner { grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 16px; }
  .brand { display: none; } /* the centred logo already shows the site name */
  .nav-links { gap: 14px; }
}
@media (max-width: 860px) {
  .topbar-inner { grid-template-columns: 1fr auto; padding: 8px 12px; min-height: 60px; }
  .logo { order: -1; text-align: left; }
  .nav-left { order: 2; grid-column: 1 / -1; }
  .brand { display: none; }
  .nav-links { display: none; flex-direction: column; gap: 0; width: 100%; padding: 6px 0; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 8px 2px; border-top: 1px solid var(--topbar-border); }
  .nav-toggle { display: inline-flex; }
  .logo-text { font-size: 1.45rem; }
  .logo-text .paren { font-size: 1.8rem; }
  .btn-ghost { padding: 7px 10px; font-size: .88rem; }
}
@media (max-width: 520px) {
  .page-title { font-size: 1.6rem; }
  .card { padding: 18px 16px 20px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .tabs { justify-content: space-between; }
  .search input { width: 100%; }
  .meta { flex-wrap: wrap; }
  .nav-right .btn-ghost { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
