/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --border: #e0ddd8;
  --text: #1a1a1a;
  --muted: #6b6860;
  --accent: #2c5f2e;
  --accent-hover: #1e4220;
  --danger: #b91c1c;
  --font: 'Georgia', serif;
  --mono: 'Menlo', 'Consolas', monospace;
  --radius: 4px;
  --code-bg: #f0ede8;
  --row-hover: #f5f3ef;
  --flash-bg: #fef3c7;
  --flash-border: #f59e0b;
  --pos: #166534;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1a;
    --surface: #252523;
    --border: #3a3835;
    --text: #e8e6e1;
    --muted: #9b9890;
    --accent: #5a9e5c;
    --accent-hover: #71b873;
    --danger: #e05252;
    --code-bg: #2e2c28;
    --row-hover: #2e2c28;
    --flash-bg: #3a2e10;
    --flash-border: #b87e0c;
    --pos: #4ade80;
  }
}

:root[data-theme="dark"] {
  --bg: #1c1c1a;
  --surface: #252523;
  --border: #3a3835;
  --text: #e8e6e1;
  --muted: #9b9890;
  --accent: #5a9e5c;
  --accent-hover: #71b873;
  --danger: #e05252;
  --code-bg: #2e2c28;
  --row-hover: #2e2c28;
  --flash-bg: #3a2e10;
  --flash-border: #b87e0c;
  --pos: #4ade80;
}

:root[data-theme="light"] {
  --bg: #fafaf8;
  --surface: #ffffff;
  --border: #e0ddd8;
  --text: #1a1a1a;
  --muted: #6b6860;
  --accent: #2c5f2e;
  --accent-hover: #1e4220;
  --danger: #b91c1c;
  --code-bg: #f0ede8;
  --row-hover: #f5f3ef;
  --flash-bg: #fef3c7;
  --flash-border: #f59e0b;
  --pos: #166534;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Layout ---------- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}

header nav {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
}

header nav .site-name {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.05em;
}

header nav ul {
  list-style: none;
  display: flex;
  gap: 1.25rem;
}

header nav ul a {
  color: var(--text);
  text-decoration: none;
  font-family: sans-serif;
  font-size: 0.9rem;
}

header nav ul a:hover { color: var(--accent); }

main {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex: 1;
  width: 100%;
}

footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
  font-family: sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- Typography ---------- */
h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 0.4rem; }
p  { margin-bottom: 0.75rem; }
a  { color: var(--accent); }
a:hover { color: var(--accent-hover); }

.muted { color: var(--muted); font-size: 0.9em; }
code { font-family: var(--mono); background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 2px; font-size: 0.9em; }

section { margin-bottom: 2rem; }

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

th {
  text-align: left;
  font-family: sans-serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  padding: 0.4rem 0.6rem;
}

td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--row-hover); }

.result { text-align: center; font-family: var(--mono); }

/* ---------- Cards / Lists ---------- */
.card-list {
  list-style: none;
}

.card-list li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.card-list li:last-child { border-bottom: none; }

.qty {
  font-family: var(--mono);
  color: var(--muted);
  min-width: 1.5rem;
  text-align: right;
}

/* ---------- Decklist Layout ---------- */
.decklist-columns {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
}

.decklist-section { flex: 1; min-width: 200px; }

/* ---------- Filters ---------- */
.filter-form {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: sans-serif;
  font-size: 0.9rem;
}

.filter-form label { display: flex; flex-direction: column; gap: 0.2rem; }

.filter-form select,
.filter-form input {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  font-family: sans-serif;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
}

.btn:hover { background: var(--accent-hover); color: #fff; }
.btn-sm { padding: 0.2rem 0.6rem; font-size: 0.8rem; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #991b1b; color: #fff; }

button[type=submit] {
  padding: 0.5rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
}

button[type=submit]:hover { background: var(--accent-hover); }

/* ---------- Video Embed ---------- */
.video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: #000;
}

.video-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* ---------- Rating Chart ---------- */
.rating-chart {
  margin: 0.5rem 0 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.25rem 0.25rem;
  overflow: hidden;
}

.pos { color: var(--pos); }
.neg { color: var(--danger); }

/* ---------- Theme Toggle ---------- */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.theme-toggle:hover { color: var(--accent); }

/* ---------- Flash Messages ---------- */
.flash-messages { margin-bottom: 1rem; }

.flash {
  padding: 0.6rem 1rem;
  background: var(--flash-bg);
  border: 1px solid var(--flash-border);
  border-radius: var(--radius);
  font-family: sans-serif;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
