/* PSU Calc — style.css */
/* Dark-mode-first, mobile-responsive, no frameworks */

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

:root {
  --bg:         #0f1117;
  --bg2:        #1a1d27;
  --bg3:        #232635;
  --border:     #2e3147;
  --accent:     #3b82f6;
  --accent-dim: #1d4ed8;
  --text:       #e2e8f0;
  --text-muted: #8892a4;
  --green:      #22c55e;
  --yellow:     #eab308;
  --red:        #ef4444;
  --radius:     10px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.site-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Desktop: two-column layout with sidebar */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 900px) {
  .content-grid {
    grid-template-columns: 1fr 300px;
  }
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.site-header .logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.site-header nav {
  margin-top: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.site-header nav a {
  color: var(--text-muted);
}
.site-header nav a:hover { color: var(--text); }

/* ─── Ad placeholders ────────────────────────────────────────────────────────── */
.ad-banner {
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.5rem;
}

.ad-banner-top    { height: 90px;  margin: 1.25rem 0; }
.ad-banner-mid    { height: 90px;  margin: 2rem 0; }
.ad-sidebar       { min-height: 250px; width: 100%; margin-bottom: 1.5rem; }

/* ─── Calculator card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 1.5rem; }

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text);
}

/* ─── Form controls ──────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field.full-width { grid-column: 1 / -1; }

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

select, input[type="number"] {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  width: 100%;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238892a4' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

select:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="number"] { text-align: center; }

/* Number spinners — hide in Chrome */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { opacity: 1; }

/* ─── Peripherals row ────────────────────────────────────────────────────────── */
.peripherals-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .peripherals-grid { grid-template-columns: repeat(2, 1fr); }
}

.peripheral-field {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.peripheral-field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.peripheral-field .unit-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.peripheral-field input {
  width: 70px;
  text-align: center;
  background: var(--bg);
}

/* ─── Result card ────────────────────────────────────────────────────────────── */
.result-card {
  background: linear-gradient(135deg, #1a2035 0%, #111520 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  text-align: center;
  margin-top: 1.5rem;
}

.result-card.hidden { display: none; }

.result-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.result-wattage {
  font-size: 4rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -2px;
}

.result-meta {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.meta-item { text-align: center; }

.meta-item .meta-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.meta-item .meta-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Headroom badge */
.headroom-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: help;
}
.headroom-great { background: rgba(34,197,94,0.15);  color: var(--green); }
.headroom-good  { background: rgba(59,130,246,0.15); color: var(--accent); }
.headroom-tight { background: rgba(234,179,8,0.15);  color: var(--yellow); }

/* ─── Breakdown table ─────────────────────────────────────────────────────────── */
.breakdown-section { margin-top: 1.5rem; }
.breakdown-section.hidden { display: none; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  padding: 0.5rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
.totals-row td { padding-top: 0.75rem; }

.text-right { text-align: right; }

.bar-cell { width: 35%; }
.bar-bg { background: var(--bg3); border-radius: 4px; height: 8px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 4px; transition: width 0.4s ease; }

/* ─── Headroom explainer ─────────────────────────────────────────────────────── */
.headroom-explainer {
  margin-top: 1.5rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.headroom-explainer.hidden { display: none; }

.headroom-explainer h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.headroom-explainer p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.headroom-explainer p:last-child { margin-bottom: 0; }

/* ─── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 1.5rem; }

.sidebar-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.sidebar-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.sidebar-card ul {
  padding-left: 1.1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tip-badge {
  display: inline-block;
  font-size: 0.7rem;
  background: rgba(59,130,246,.15);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.4rem;
}

/* ─── Main page H1 area ──────────────────────────────────────────────────────── */
.page-hero {
  padding: 2rem 0 0.5rem;
}

.page-hero h1 {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.5px;
}

.page-hero p {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 600px;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer {
  margin-top: 3rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
}

.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text); }

/* ─── Guide page ─────────────────────────────────────────────────────────────── */
.article-body {
  max-width: 720px;
}

.article-body h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  color: var(--text);
}

.article-body p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  line-height: 1.75;
}

.article-body ul {
  padding-left: 1.25rem;
  margin-bottom: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.cta-box {
  background: linear-gradient(135deg, #1a2035 0%, #111520 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 2rem 0;
  text-align: center;
}

.cta-box p { color: var(--text); margin-bottom: 0.75rem; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.btn:hover { background: var(--accent-dim); text-decoration: none; }

/* ─── Utility ─────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.error { color: var(--red); font-size: 0.9rem; padding: 1rem 0; }
