/*
 * Fan Town design system. Dark-first and cinematic: the artwork is the interface.
 * One accent (--accent) used only for ratings and the primary action, never decoration.
 * Area-specific styles live in sibling files (channels.css, profiles.css, ...).
 */

:root {
  --bg: #0b0c10;
  --bg-raised: #13151b;
  --bg-sunken: #08090c;
  --surface: #181b23;
  --surface-hover: #20242e;
  --border: #252934;
  --border-strong: #343a48;
  --text: #ece9e2;
  --text-soft: #b9b6ae;
  --muted: #7f8494;
  --accent: #f5b83d;
  --accent-ink: #1a1306;
  --danger: #ef6a5b;
  --success: #6fcf97;
  --heart: #ff5d7a;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --container: 1180px;
  --gutter: clamp(16px, 4vw, 32px);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]).allow-light {
    --bg: #f6f3ec;
    --bg-raised: #ffffff;
    --surface: #ffffff;
    --surface-hover: #f0ece2;
    --border: #e2ddd1;
    --border-strong: #cfc8b8;
    --text: #17181c;
    --text-soft: #3e4048;
    --muted: #6d7180;
    color-scheme: light;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }
a:hover { color: #fff; }
p a, .prose a { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }

h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: clamp(28px, 4vw, 44px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

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

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.container--narrow { max-width: 760px; }

.muted { color: var(--muted); }
.soft { color: var(--text-soft); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.serif { font-family: var(--font-serif); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 32px; }
.page { padding-top: 32px; padding-bottom: 64px; }

/* Section heading: small caps label with a hairline, as on Letterboxd */
.section { margin-top: 40px; }
.section__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 16px;
}
.section__title { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-soft); margin: 0; }
.section__more { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.section__more:hover { color: var(--text); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11, 12, 16, .82);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.topbar__inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); }
.brand__name { font-family: var(--font-serif); font-weight: 600; font-size: 20px; letter-spacing: -.01em; }
.mark { color: var(--text); flex: none; }
.nav { display: flex; gap: 4px; }
.nav__link { padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text-soft); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.nav__link:hover, .nav__link.is-active { color: var(--text); }
.topbar__search { flex: 1; max-width: 300px; margin-left: auto; }
.topbar__search input { width: 100%; height: 34px; border-radius: 999px; padding: 0 14px; background: var(--surface); border: 1px solid transparent; color: var(--text); font: inherit; font-size: 13px; }
.topbar__search input:focus { border-color: var(--border-strong); outline: none; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px; z-index: 50;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column;
}
.menu__panel a, .menu__button { padding: 8px 10px; border-radius: var(--radius-sm); font-size: 14px; color: var(--text-soft); background: none; border: 0; text-align: left; font: inherit; cursor: pointer; width: 100%; }
.menu__panel a:hover, .menu__button:hover { background: var(--surface); color: var(--text); }
.menu__panel form { margin: 0; }

@media (max-width: 860px) {
  .nav, .topbar__search { display: none; }
  .topbar__actions { margin-left: auto; }
}

/* ---------- Flash ---------- */
.flashes { padding-top: 16px; }
.flash { margin: 0 0 8px; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; background: var(--surface); border: 1px solid var(--border); }
.flash--alert { border-color: rgba(239, 106, 91, .4); color: #ffc1b8; }
.flash--notice { border-color: rgba(111, 207, 151, .35); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-hover); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: #ffc85a; color: var(--accent-ink); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface); }
.btn--danger { color: var(--danger); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.button_to { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.link-button:hover { color: var(--text); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label, .label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-soft); }
.input, .field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="url"],
.field input[type="date"], .field input[type="search"], .field input[type="number"], .field select, .field textarea, .textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-sunken); color: var(--text); font: inherit; font-size: 15px;
}
.field textarea, .textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.textarea--review { font-family: var(--font-serif); font-size: 17px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus, .textarea:focus { outline: none; border-color: var(--text-soft); }
.field__hint { font-size: 13px; color: var(--muted); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-soft); cursor: pointer; }
.checkbox input { accent-color: var(--accent); width: 16px; height: 16px; }
.errors { padding: 12px 14px; border-radius: var(--radius); border: 1px solid rgba(239, 106, 91, .4); color: #ffc1b8; font-size: 14px; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

.card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.auth { max-width: 420px; margin: 56px auto; }
.auth h1 { font-family: var(--font-serif); font-weight: 500; font-size: 32px; }
.auth__google { display: block; margin: 20px 0 0; }
.auth__google-note { margin: 8px 0 0; text-align: center; }
.btn--google { gap: 10px; height: 44px; }

/* ---------- Avatars ---------- */
.avatar {
  width: var(--size, 40px); height: var(--size, 40px); border-radius: 50%; object-fit: cover; flex: none;
  background: var(--surface); box-shadow: 0 0 0 1px rgba(255, 255, 255, .06);
}
.avatar--monogram {
  display: inline-grid; place-items: center; font-weight: 700; color: #fff;
  font-size: calc(var(--size, 40px) * .42);
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--accent-bg) 85%, white), var(--accent-bg));
}

/* ---------- Ratings: the only place the accent appears besides primary actions ---------- */
.stars { color: var(--accent); letter-spacing: .02em; white-space: nowrap; }
.stars--sm { font-size: 13px; }
.stars--md { font-size: 16px; }
.stars--lg { font-size: 22px; }
.stars__half { font-size: .85em; margin-left: 1px; }
.rating-big { font-family: var(--font-serif); font-size: 40px; font-weight: 500; line-height: 1; }

.hist { display: block; overflow: visible; }
.hist__bar { fill: color-mix(in srgb, var(--text) 40%, transparent); transition: fill .15s; }
.hist__bar:hover { fill: var(--accent); }
.hist__bar--empty { fill: var(--border); }
.ratings-panel { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: end; }
.ratings-panel__legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); grid-column: 2; }

.spark { width: 100%; height: 80px; display: block; }
.spark__line { stroke: var(--text-soft); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark__area { fill: color-mix(in srgb, var(--text) 7%, transparent); }

/* Interactive half-star picker (rating_controller.js) */
.star-input { display: inline-flex; align-items: center; gap: 2px; }
.star-input__star { position: relative; width: 34px; height: 34px; cursor: pointer; color: var(--border-strong); font-size: 32px; line-height: 34px; text-align: center; user-select: none; transition: transform .18s cubic-bezier(.3, 1.6, .5, 1); }
.star-input__star::before { content: "★"; }
.star-input__star .star-input__fill { position: absolute; inset: 0; overflow: hidden; color: var(--accent); width: 0; }
.star-input__star .star-input__fill::before { content: "★"; }
.star-input__star.is-half .star-input__fill { width: 50%; }
.star-input__star.is-full .star-input__fill { width: 100%; }
.star-input__star.is-pop { transform: scale(1.25); }
.star-input__clear { margin-left: 8px; }
.star-input__value { margin-left: 10px; min-width: 32px; font-family: var(--font-serif); font-size: 18px; color: var(--text-soft); }

.like-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-size: 14px; }
.like-toggle input { display: none; }
.like-toggle__heart { font-size: 22px; transition: transform .2s cubic-bezier(.3, 1.6, .5, 1), color .15s; }
.like-toggle input:checked + .like-toggle__heart { color: var(--heart); transform: scale(1.15); }

/* ---------- Artwork grids ---------- */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.thumb-grid--sm { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.thumb { display: block; }
.thumb__img {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--surface);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06);
}
.thumb__img img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease, filter .35s; }
.thumb:hover .thumb__img img { transform: scale(1.03); filter: brightness(1.08); }
.thumb:hover .thumb__img { box-shadow: 0 0 0 2px var(--text-soft); }
.thumb__duration { position: absolute; right: 6px; bottom: 6px; background: rgba(0, 0, 0, .78); font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 4px; }
.thumb__title { margin-top: 8px; font-size: 14px; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumb__meta { margin-top: 2px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 16px; }
.channel-tile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.channel-tile .avatar { transition: box-shadow .2s, transform .2s; }
.channel-tile:hover .avatar { box-shadow: 0 0 0 2px var(--text); transform: translateY(-2px); }
.channel-tile__name { font-size: 14px; font-weight: 600; line-height: 1.25; }
.channel-tile__meta { font-size: 12px; color: var(--muted); margin-top: -6px; }

.channel-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.channel-row__rank { width: 28px; font-family: var(--font-serif); font-size: 22px; color: var(--muted); text-align: right; flex: none; }
.channel-row__body { flex: 1; min-width: 0; }
.channel-row__name { font-weight: 600; }
.channel-row__desc { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-row__score { text-align: right; flex: none; }

/* ---------- Reviews: they read like writing ---------- */
.review { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.review:last-child { border-bottom: 0; }
.review__head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--muted); }
.review__author { color: var(--text); font-weight: 600; }
.review__subject { color: var(--text-soft); font-weight: 600; }
.review__body { font-family: var(--font-serif); font-size: 17px; line-height: 1.6; color: var(--text); margin-top: 8px; overflow-wrap: anywhere; }
.review__body p { margin: 0 0 .7em; }
.review__foot { display: flex; align-items: center; gap: 16px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.review__hearted { color: var(--heart); font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: var(--surface); color: var(--text-soft); border: 1px solid var(--border-strong); }
.badge--rotw { color: var(--text); border-color: var(--text-soft); }
.badge--claimed { color: var(--text); }
.badge--founding { color: var(--text); }

.flair { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--surface); color: var(--text-soft); }
.flair--veteran { background: #2a2f3d; color: #e3e6ef; }
.flair--verified { background: rgba(255, 255, 255, .06); color: var(--text); }
.flair--mod { background: rgba(111, 207, 151, .12); color: var(--success); }

/* Vote buttons */
.vote { display: inline-flex; align-items: center; gap: 4px; }
.vote__btn { background: none; border: 0; padding: 2px 4px; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; border-radius: 4px; }
.vote__btn:hover { color: var(--text); background: var(--surface); }
.vote__btn.is-on { color: var(--text); }
.vote__btn--like.is-on { color: var(--heart); }
.vote__count { font-size: 13px; color: var(--text-soft); min-width: 1ch; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 12px 14px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.is-active { color: var(--text); border-bottom-color: var(--text); }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { padding: 5px 12px; border-radius: 999px; font-size: 13px; color: var(--text-soft); background: var(--surface); border: 1px solid var(--border); }
.pill:hover { color: var(--text); border-color: var(--border-strong); }
.pill.is-active { color: var(--bg); background: var(--text); border-color: var(--text); }

/* ---------- Layout helpers ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; }
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; gap: 32px; } }
.sidebar > * + * { margin-top: 32px; }
.stat-row { display: flex; gap: 28px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat__value { font-family: var(--font-serif); font-size: 24px; font-weight: 500; line-height: 1.1; }
.stat__label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); font-size: 14px; }
.empty .serif { font-size: 18px; color: var(--text-soft); display: block; margin-bottom: 6px; }

.prose { font-family: var(--font-serif); font-size: 19px; line-height: 1.7; color: var(--text); }
.prose h2, .prose h3 { font-family: var(--font-sans); margin-top: 1.6em; }
.prose blockquote { margin: 1.2em 0; padding-left: 18px; border-left: 2px solid var(--border-strong); color: var(--text-soft); font-style: italic; }

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 28px; }

/* ---------- Modal (turbo-frame#modal) ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 8, .72); backdrop-filter: blur(6px); animation: fade-in .15s ease-out; }
.modal__panel { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; animation: rise .2s cubic-bezier(.2, .9, .3, 1.1); }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__close { background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 28px 0 40px; color: var(--muted); font-size: 13px; }
.footer__inner { display: grid; gap: 12px; }
.footer__brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-serif); font-style: italic; font-size: 16px; color: var(--text-soft); }
.footer__nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer__nav a:hover { color: var(--text); }
.footer__legal { margin: 0; font-size: 12px; }
