/*
Theme Name: VideoPinball
Description: Dark violet compendium theme for VideoPinball.org. Pairs with the VideoPinball Core plugin.
Author: Shaun Root
Version: 1.0.0
*/

:root {
  --bg: #0c0b12; --bg-deep: #08070d;
  --surface: #14131d; --surface-2: #1a1927;
  --line: #26243a; --line-lit: #3b3760;
  --text: #eeedf6; --muted: #918fa6; --faint: #5d5a75;
  --violet: #8b5cf6; --violet-deep: #6d3ee0; --violet-soft: #8b5cf61f;
  --lavender: #c4b3fb;
  --pink: #ff2e88;
  --green: #3fce7f; --green-deep: #1fa35c;
  --d70: #ff2e88; --d80: #ff7a3d; --d90: #ffb545;
  --d00: #2dd4bf; --d10: #4ac1ff; --d20: #8b5cf6; --dx: #6b6885;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: 'Space Grotesk', system-ui, sans-serif; font-size: 15px; line-height: 1.45; }
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }
select { font: inherit; }

/* ---------- header ---------- */
header { position: sticky; top: 0; z-index: 20; background: #08070df0; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.head-inner { max-width: 1180px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 21px; letter-spacing: .5px; white-space: nowrap; text-decoration: none; color: var(--text); }
.logo b { font-weight: 700; background: linear-gradient(120deg, var(--lavender), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo .tld { color: var(--pink); font-weight: 600; }
.logo-img { height: 46px; width: auto; display: block; }
.search { flex: 1; min-width: 180px; max-width: 400px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; }
.search:focus-within { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }
.search svg { flex: none; color: var(--faint); }
.search input { background: none; border: none; outline: none; width: 100%; color: var(--text); font: inherit; font-size: 13.5px; }
.search input::placeholder { color: var(--faint); }
.stats { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.stat { font-family: 'Chakra Petch', sans-serif; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 12px; letter-spacing: .5px; color: var(--muted); }
.stat b { color: var(--lavender); font-weight: 600; margin-right: 4px; }
.add { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; }
.add:hover { color: var(--lavender); border-color: var(--violet); }
.add svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2.6; fill: none; stroke-linecap: round; }

.advbtn { display: inline-flex; align-items: center; gap: 7px; font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 11.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; }
.advbtn:hover, .advbtn[aria-expanded="true"] { color: var(--lavender); background: #8b5cf62a; border-color: #8b5cf680; }
.advbtn svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.advpanel { max-height: 0; overflow: hidden; transition: max-height .25s ease; background: var(--bg-deep); }
@media (prefers-reduced-motion: reduce) { .advpanel { transition: none; } }
.advpanel.open { max-height: 320px; }
.adv-inner { max-width: 1180px; margin: 0 auto; padding: 14px 24px 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 16px; }
.adv-inner label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); font-family: 'Chakra Petch', sans-serif; font-weight: 600; }
.adv-inner input[type="text"], .adv-inner input[type="number"] { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; color: var(--text); font: inherit; font-family: 'Space Grotesk', sans-serif; font-size: 13px; outline: none; }
.adv-inner input:focus { border-color: var(--violet); }
.adv-check { flex-direction: row !important; align-items: center; gap: 8px !important; align-self: end; padding-bottom: 8px; }
.adv-check input { accent-color: var(--violet); width: 15px; height: 15px; }
.adv-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.adv-hint { font-size: 12px; color: var(--faint); margin-right: auto; }
.adv-apply, .adv-reset { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 11.5px; letter-spacing: .8px; text-transform: uppercase; border-radius: 7px; padding: 7px 14px; border: 1px solid var(--line); color: var(--muted); }
.adv-apply { background: #8b5cf62a; border-color: #8b5cf680; color: #c9b8fd; }
.adv-reset:hover { color: var(--text); border-color: var(--line-lit); }

/* ---------- filters ---------- */
.filterbar { border-top: 1px solid var(--line); background: var(--bg-deep); }
.filter-inner { max-width: 1180px; margin: 0 auto; padding: 9px 24px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.fsel { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; font-size: 12.5px; max-width: 220px; outline: none; }
.fsel:focus { border-color: var(--violet); }
.chips-group { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.fchip { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 11px; letter-spacing: .6px; border: 1px solid var(--line); border-radius: 99px; padding: 4px 11px; color: var(--muted); }
.fchip:hover { color: var(--text); border-color: var(--line-lit); }
.fchip.on { background: var(--surface-2); color: var(--text); border-color: var(--line-lit); }
.fchip[data-dec] { border-color: color-mix(in srgb, var(--dc) 45%, transparent); color: var(--dc); }
.fchip[data-dec].on { background: var(--dc); color: #0d0c14; border-color: var(--dc); }
.fchip.st-played.on { background: #3fce7f26; border-color: #3fce7f75; color: #9ae8bd; }
.fchip.st-wish.on { background: #8b5cf62a; border-color: #8b5cf680; color: #c9b8fd; }
.fsep { width: 1px; height: 18px; background: var(--line); }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 24px 80px; display: grid; grid-template-columns: 48px 1fr; gap: 24px; }
nav.rail { position: sticky; top: calc(var(--headh, 110px) + 20px); align-self: start; display: flex; flex-direction: column; gap: 1px; max-height: calc(100vh - 145px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 4px; scrollbar-width: none; }
nav.rail::-webkit-scrollbar { display: none; }
nav.rail.off { opacity: .25; pointer-events: none; }
nav.rail button, nav.rail .dead { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 11.5px; text-align: center; padding: 3px 2px; border-radius: 5px; }
nav.rail button { color: var(--muted); }
nav.rail button:hover, nav.rail button:focus-visible { color: var(--lavender); background: #8b5cf62a; outline: none; }
nav.rail .dead { color: #38364a; }
nav.rail button[data-dec] { color: var(--dc); }
nav.rail button[data-dec]:hover { background: color-mix(in srgb, var(--dc) 18%, transparent); color: var(--dc); }

/* ---------- sort bar ---------- */
.sortbar { position: sticky; top: calc(var(--headh, 110px) + 8px); z-index: 15; display: grid; grid-template-columns: minmax(0, 2.4fr) 76px minmax(0, 1.6fr) minmax(0, 1.2fr) 54px 158px; gap: 14px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 16px; margin-bottom: 10px; }
.sortbar button { display: flex; align-items: center; gap: 6px; font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 11.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); padding: 3px 0; text-align: left; }
.sortbar button:hover { color: var(--lavender); }
.sortbar button .arr { font-size: 10px; opacity: 0; }
.sortbar [data-k="r"] { white-space: normal; line-height: 1.2; }
.sortbar button.on { color: var(--lavender); }
.sortbar button.on .arr { opacity: 1; color: var(--pink); }
.sort-shelf { display: flex; gap: 8px; justify-content: flex-end; }
.sort-shelf button { font-size: 10.5px !important; letter-spacing: .8px !important; }

/* ---------- rows ---------- */
.rows { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: minmax(0, 2.4fr) 76px minmax(0, 1.6fr) minmax(0, 1.2fr) 54px 158px; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; position: relative; background: linear-gradient(90deg, var(--surface) 62%, color-mix(in srgb, var(--dc) 9%, var(--surface))); }
.row:hover { border-color: var(--line-lit); background: linear-gradient(90deg, var(--surface-2) 55%, color-mix(in srgb, var(--dc) 15%, var(--surface-2))); }
.row.hidden { display: none; }
.d70 { --dc: var(--d70); } .d80 { --dc: var(--d80); } .d90 { --dc: var(--d90); }
.d00 { --dc: var(--d00); } .d10 { --dc: var(--d10); } .d20 { --dc: var(--d20); } .dx { --dc: var(--dx); }
.row h3 { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.row h3 a { color: inherit; text-decoration: none; }
.row.linked h3 a::after { content: ""; position: absolute; inset: 0; border-radius: 10px; }
.row.linked:hover h3 a { color: var(--lavender); }
.row.linked { cursor: pointer; }
.note { font-size: 12px; color: var(--faint); margin-top: 2px; overflow-wrap: anywhere; position: relative; z-index: 1; }
.ypill { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 13.5px; letter-spacing: .5px; color: var(--dc); }
.c-sys { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; color: var(--muted); background: var(--bg-deep); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; white-space: nowrap; cursor: pointer; position: relative; z-index: 2; }
.chip:hover { border-color: var(--violet); color: var(--lavender); }
.c-dev { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.c-act { display: flex; gap: 6px; justify-content: flex-end; position: relative; z-index: 2; }
.tog { display: inline-flex; align-items: center; gap: 5px; font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); background: var(--bg-deep); border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; }
.tog svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tog.played:hover { border-color: var(--green); color: var(--green); }
.tog.wish:hover { border-color: var(--violet); color: var(--lavender); }
.tog.played[aria-pressed="true"] { background: #3fce7f26; border-color: #3fce7f75; color: #9ae8bd; }
.tog.played[aria-pressed="true"]:hover { background: #3fce7f3d; border-color: #6adb9c; color: #bdf2d4; }
.tog.wish[aria-pressed="true"] { background: #8b5cf62a; border-color: #8b5cf680; color: #c9b8fd; }
.tog.wish[aria-pressed="true"]:hover { background: #8b5cf640; border-color: #a583f8; color: #ddd1fe; }
.tog.wish[aria-pressed="true"] svg { fill: #c9b8fd; stroke: #c9b8fd; }
.none { color: #3f3d52; font-size: 13px; }
a:focus-visible, button:focus-visible, select:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.empty { display: none; text-align: center; color: var(--faint); padding: 48px 0; font-size: 14px; }
.empty.show { display: block; }

footer { border-top: 1px solid var(--line); background: var(--bg-deep); padding: 22px 24px; text-align: center; font-size: 12.5px; color: var(--faint); letter-spacing: .3px; }
footer b { color: var(--muted); font-weight: 500; }

@media (max-width: 900px) {
  .sortbar, .row { grid-template-columns: minmax(0, 2fr) 64px minmax(0, 1.4fr) 54px 150px; }
  .c-dev, .sortbar [data-k="d"] { display: none; }
}
@media (max-width: 640px) {
  .head-inner { gap: 8px; }
  .stats { margin-left: 0; }
  .wrap { grid-template-columns: 38px 1fr; gap: 12px; padding: 16px 12px 60px; }
  .sortbar { grid-template-columns: 1fr 64px 150px; position: static; }
  .sortbar [data-k="s"], .sortbar [data-k="r"], .c-real { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) 150px; gap: 8px; padding: 10px 12px; }
  .c-year { order: 3; }
  .c-sys { order: 4; grid-column: 1 / -1; }
  .c-act { order: 2; }
  nav.rail { top: 12px; }
}


/* ---------- sim/fantasy gauge ---------- */
.gauge { position: relative; display: block; width: 46px; height: 45px; }
.gauge img { position: absolute; inset: 0; width: 100%; height: 100%; }
.gauge .gneedle { transform-origin: 48.6% 73.8%; transform: rotate(var(--rot, 0deg)); }
.gauge.unrated { opacity: .3; }
.game-single .gauge { width: 92px; height: 90px; }

/* ---------- single game page ---------- */
.game-single { max-width: 760px; margin: 0 auto; padding: 40px 24px 80px; }
.game-single .back { font-family: 'Chakra Petch', sans-serif; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); text-decoration: none; }
.game-single .back:hover { color: var(--lavender); }
.game-card { margin-top: 18px; background: linear-gradient(120deg, var(--surface) 55%, color-mix(in srgb, var(--dc) 10%, var(--surface))); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.game-card h1 { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 28px; line-height: 1.2; overflow-wrap: anywhere; }
.game-card .gyear { font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 16px; color: var(--dc); margin-top: 4px; }
.game-meta { margin-top: 20px; display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; font-size: 14px; }
.game-meta dt { font-family: 'Chakra Petch', sans-serif; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); padding-top: 2px; }
.game-meta dd { color: var(--text); overflow-wrap: anywhere; }
.game-meta dd a { color: var(--lavender); }
.game-actions { margin-top: 24px; display: flex; gap: 8px; flex-wrap: wrap; }
.game-content { margin-top: 24px; color: var(--muted); font-size: 14.5px; }

/* ---------- add game page ---------- */
.add-page { max-width: 640px; margin: 0 auto; padding: 40px 24px 80px; }
.add-page h1 { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 24px; margin-bottom: 6px; }
.add-page .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.add-form { display: grid; gap: 14px; }
.add-form label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); font-family: 'Chakra Petch', sans-serif; font-weight: 600; }
.add-form input { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; color: var(--text); font-family: 'Space Grotesk', sans-serif; font-size: 14px; outline: none; }
.add-form input:focus { border-color: var(--violet); }
.add-form .submit { justify-self: start; font-family: 'Chakra Petch', sans-serif; font-weight: 600; font-size: 12px; letter-spacing: .8px; text-transform: uppercase; background: #8b5cf62a; border: 1px solid #8b5cf680; color: #c9b8fd; border-radius: 8px; padding: 10px 18px; cursor: pointer; }
.add-form .submit:hover { background: #8b5cf640; border-color: #a583f8; color: #ddd1fe; }
.vp-notice { background: var(--surface); border: 1px solid #3fce7f75; color: #9ae8bd; border-radius: 8px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 20px; }

/* ----- inline editing (editors only) ----- */
.ed { cursor: text; border-radius: 5px; box-decoration-break: clone; transition: background .12s, box-shadow .12s; }
.ed:hover { background: var(--violet-soft); box-shadow: 0 0 0 3px var(--violet-soft); }
.ed:focus-visible { outline: none; background: var(--violet-soft); box-shadow: 0 0 0 2px var(--violet); }
.gauge.ed { cursor: pointer; }
.gauge.ed:hover { box-shadow: 0 0 0 3px var(--violet-soft); }

.ed.editing { background: none; box-shadow: none; }
.ed.saving { opacity: .55; }
.ed.save-error { background: #ef44441f; box-shadow: 0 0 0 3px #ef44441f; }

.ed-input { width: 100%; min-width: 0; background: var(--surface-2); border: 1px solid var(--violet); border-radius: 6px; padding: 3px 7px; color: var(--text); font: inherit; font-size: inherit; font-family: inherit; outline: none; }
.c-real .ed-input { width: 46px; text-align: center; font-size: 13px; }

/* Permalink shown beside an editable title, since the title itself opens the editor. */
.openlink { margin-left: 7px; color: var(--faint); text-decoration: none; font-size: 12px; opacity: 0; transition: opacity .12s, color .12s; }
.row:hover .openlink, .openlink:focus-visible { opacity: 1; }
.openlink:hover { color: var(--lavender); }
