/* GunSizer — Main Site Styles */

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

/* ── Light theme (default) ── */
body {
    --grid-color:   rgba(0,0,0,0.08);
    --bg:           #f4f3ee;
    --surface:      #ffffff;
    --surface2:     #f0efe9;
    --border:       #dddcd6;
    --accent:       #9a7a28;
    --accent-hover: #b8973a;
    --text:         #1a1a1a;
    --text-muted:   #888;
    --radius:       6px;
    --gun1:         #1a6fd4;
    --gun2:         #c94a2a;
}

/* ── Dark theme ── */
body.dark {
    --grid-color:   rgba(255,255,255,0.07);
    --bg:           #1a1a1a;
    --surface:      #242424;
    --surface2:     #2e2e2e;
    --border:       #3a3a3a;
    --accent:       #b8973a;
    --accent-hover: #d4af55;
    --text:         #e8e8e8;
    --text-muted:   #777;
    --gun1:         #4a9eff;
    --gun2:         #ff6b4a;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    transition: background 0.2s, color 0.2s;
}

/* ── Header ── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--accent);
    text-transform: uppercase;
}
header h1 span { color: var(--text); font-weight: 300; }

.header-nav { display: flex; align-items: center; gap: 1rem; }

.sponsor {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-left: auto;
    align-self: stretch;
    border-left: 1px solid var(--border);
    padding-left: 1.5rem;
}
.sponsor-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    white-space: nowrap;
}
.sponsor a { display: flex; align-items: center; }
.sponsor img { height: 100%; max-height: 90px; width: auto; }

header nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: color 0.2s;
}
header nav a:hover { color: var(--accent); }

/* ── Theme toggle button ── */
.theme-toggle {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.theme-toggle:hover { color: var(--text); background: var(--border); }
.theme-toggle .icon { font-size: 1rem; line-height: 1; }

/* ── Main layout ── */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ── Selector panel ── */
.selector-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
}

.selector-panel h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.selectors {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.selector-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
    min-width: 200px;
}

.selector-group label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.gun-label-1 { color: var(--gun1); }
.gun-label-2 { color: var(--gun2); }

select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.55rem 2rem 0.55rem 0.75rem;
    font-size: 0.95rem;
    cursor: pointer;
    appearance: none;
    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 fill='%23888' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    transition: background 0.2s, color 0.2s;
}
select:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* foreground toggle */
.fg-toggle { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.fg-toggle span {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.radio-btn { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; font-size: 0.9rem; }
.radio-btn input { accent-color: var(--accent); cursor: pointer; }

/* ── Comparison stage ── */
.stage-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem 0.75rem 0.25rem;
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: 36px 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 0;
    row-gap: 0;
}

.stage {
    grid-column: 2;
    grid-row: 1;
    position: relative;
    min-height: 120px;
    background-image:
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
    background-position: left bottom;
    /* background-size set inline from PHP: gun_px_width(1) x gun_px_width(1) */
}

.gun-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
}

.gun-overlay img {
    display: block;
    height: auto;
    transition: width 0.3s;
}

.gun-overlay.foreground { z-index: 10; }
.gun-overlay.background { z-index: 5; }
.gun-overlay.background img { filter: brightness(0.6) saturate(0.6); }

/* ── Scale legend ── */
.scale-legend {
    grid-column: 1 / -1;
    grid-row: 3;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}
.scale-bar {
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
}

/* ── Info cards ── */
.info-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}

.info-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.info-card .manufacturer {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-card.card-1 { border-top: 3px solid var(--gun1); }
.info-card.card-2 { border-top: 3px solid var(--gun2); }

.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; }

.spec { display: flex; flex-direction: column; }
.spec .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.spec .value { font-size: 0.95rem; font-weight: 500; }

.notes-row {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Rulers ── */
.ruler-x {
    grid-column: 2;
    grid-row: 2;
    position: relative;
    height: 28px;
    pointer-events: none;
    border-top: 1px solid var(--text-muted);
    opacity: 0.8;
}
.ruler-y {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    width: 36px;
    pointer-events: none;
    align-self: end;
    border-right: 1px solid var(--text-muted);
    opacity: 0.8;
}
/* X ticks: point upward from top of ruler-x */
.tick-x {
    position: absolute;
    top: 0;
    width: 1px;
    height: 6px;
    background: var(--text-muted);
    opacity: 0.5;
}
.tick-x.major { height: 10px; opacity: 0.8; }
.tick-x span {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}
/* Y ticks: point rightward from right edge of ruler-y */
.tick-y {
    position: absolute;
    right: 0;
    height: 1px;
    width: 6px;
    background: var(--text-muted);
    opacity: 0.5;
}
.tick-y.major { width: 10px; opacity: 0.8; }
.tick-y span {
    position: absolute;
    right: 12px;
    top: -8px;
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    text-align: right;
}

/* ── Placeholder ── */
.stage-placeholder {
    text-align: center;
    padding: 4rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Footer ── */
footer {
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 680px) {
    header { padding: 0 1rem; }
    header h1 { font-size: 1.2rem; }
    .info-cards { grid-template-columns: 1fr; }
    .selectors { flex-direction: column; }
    .theme-toggle .label { display: none; }
}
