/* ====== Futuristic Synthwave HUD Theme ====== */
:root {
    --bg-0: #060a12;
    --bg-1: #0c1221;
    --grid: rgba(0, 231, 255, 0.12);
    --scan: rgba(0, 231, 255, 0.06);
    --neon: #00e7ff;
    --magenta: #ff2fd6;
    --amber: #e6c47a; /* Spice accent */
    --text: #e9fbff;
    --panel: rgba(8, 14, 24, 0.72);
    --panel-fill: #0a1220; /* high-contrast solid fill */
    --panel-border: rgba(0, 231, 255, 0.35);
    --shadow: rgba(0, 231, 255, 0.25);
    --notch: 14px; /* cut-corner size */
    /* Group input layout widths */
    --group-label-w: 96px;
    --group-size-w: 7ch;
}

/* Global base */
* { box-sizing: border-box; }
body {
    font-family: 'Orbitron', 'Segoe UI', Arial, sans-serif;
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background:
      radial-gradient(1200px 700px at 12% 10%, #0e1730 0%, transparent 60%),
      radial-gradient(900px 600px at 88% 12%, #170b27 0%, transparent 55%),
      linear-gradient(180deg, var(--bg-1), var(--bg-0));
    position: relative;
    overflow-x: hidden;
}

/* Layout: container + right-side group results */
.page-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;           /* align tops; control offset via margin */
    gap: 0;                            /* no gap when groups are hidden */
}
body.groups-active .page-layout { gap: 24px; }

/* Grid removed per request */

/* Soft scanlines for a HUD vibe */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        180deg,
        transparent 0 2px,
        var(--scan) 2px 4px
    );
}

@keyframes grid-pan {
    0%   { background-position: 0 0, 0 0; }
    100% { background-position: 0 28px, 28px 0; }
}

h1, h2, .credit, label, input, button, .result, p {
    font-family: 'Orbitron', 'Segoe UI', Arial, sans-serif;
}

h1 {
    letter-spacing: 2px;
    font-size: 2.6em;
    margin: 6px 0 12px;
    color: var(--text);
    text-shadow: 0 0 10px rgba(0, 231, 255, 0.35), 0 0 30px rgba(255, 47, 214, 0.25);
}

.glow {
    background: linear-gradient(90deg, var(--neon), var(--magenta));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.badge {
    display: inline-block;
    font-size: 0.45em;
    padding: 2px 8px;
    margin-left: 8px;
    border-radius: 999px;
    color: #021014;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(90deg, var(--neon), var(--magenta));
    box-shadow: 0 0 14px rgba(0, 231, 255, 0.45);
}
/* Animated flashing cursor for input fields */
.input-cursor {
    display: inline-block;
    width: 1ch;
    height: 1.2em;
    vertical-align: middle;
    background: var(--neon);
    margin-left: 2px;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(0, 231, 255, 0.65);
    opacity: 1; /* default visible */
}

/* Synchronize all cursor flashes via a single body class */
body.cursor-off .input-cursor { opacity: 0; }

/* legacy keyframes no longer used */
/* Hide number input spinners (Chrome, Safari, Edge) */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
/* Hide number input spinners (Firefox) */
input[type=number] {
    -moz-appearance: textfield;
}
/* Toggle Switch Styles */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 6px; /* tighter space between toggle and label */
    min-height: 30px; /* match switch height for vertical centering */
    margin-bottom: 12px; /* reduce vertical spacing between rows */
}
.switch {
    position: relative;
    display: inline-block;
    width: 54px;
    height: 30px;
    margin-right: 0; /* rely on .toggle-wrapper gap for spacing */
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #0e1524;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    transition: .35s;
    box-shadow: 0 0 10px rgba(0, 231, 255, 0.25) inset;
}
.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 3px;
    background: linear-gradient(90deg, var(--neon), var(--magenta));
    border-radius: 6px;
    transition: .35s;
    box-shadow: 0 0 12px rgba(0, 231, 255, 0.65);
}
.switch input:checked + .slider {
    background: radial-gradient(120px 40px at 30% 20%, rgba(0, 231, 255, 0.15), transparent) #08101c;
    border-color: var(--neon);
    box-shadow: 0 0 16px rgba(0, 231, 255, 0.35) inset, 0 0 10px rgba(0, 231, 255, 0.25);
}
.switch input:checked + .slider:before {
    transform: translateX(22px);
    background: linear-gradient(90deg, var(--magenta), var(--neon));
}
#discount-label, #mode-label, #group-mode-label {
    color: var(--amber);
    font-size: 1.05rem; /* use rem to avoid parent em scaling */
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center; /* vertically center text to switch */
    height: 30px; /* match .switch height */
    line-height: 30px;
}

/* Group panel layout: single column list */
#group-results {
    display: flex;
    flex-direction: column;            /* one column, all groups stacked */
    gap: 12px;                         /* vertical spacing between groups */
}

/* Group card with vertical lines */
#group-results .group-card { font-size: 0.98em; }
#group-results .group-card .name { font-weight: 700; margin-bottom: 2px; }
#group-results .group-card .line { opacity: 0.95; }
#group-results .group-card .label { color: var(--amber); }

/* Thin divider between groups, matching container border tone */
#group-results .group-card {
    padding-bottom: 8px;
}
#group-results .group-card { opacity: 0; transform: translateY(var(--drop, 8px)); will-change: opacity, transform; }
#group-results .group-card.build-in { animation: group-build 350ms ease forwards; }
#group-results .group-card.build-in:nth-child(n) { will-change: opacity, transform; }
#group-results .group-card::after {
    content: "";
    display: block;
    width: 50%;                  /* half-length divider */
    height: 1px;
    background: rgba(0, 231, 255, 0.6);
    margin-top: 8px;
}
#group-results .group-card:last-child {
    padding-bottom: 0;
}
#group-results .group-card:last-child::after {
    content: none;
}

@keyframes group-build {
    from { opacity: 0; transform: translateY(var(--drop, 8px)); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 520px) {
    /* nothing special needed for each line in narrow view */
}
.container {
    max-width: 640px; /* widened to fit both toggles on one line */
    margin: 42px 0;
    padding: 34px 28px 0 28px;
    margin-bottom: -4px;
    position: relative;
    /* Solid, high-contrast fill for maximum readability */
    background: var(--panel-fill);
    border: 2px solid rgba(0, 231, 255, 0.6);
    box-shadow:
      0 10px 30px rgba(0, 0, 0, 0.35),
      0 0 22px rgba(0, 231, 255, 0.18),
      0 0 0 1px rgba(0, 231, 255, 0.15) inset;
    backdrop-filter: blur(6px) saturate(120%);
    clip-path: polygon(
      var(--notch) 0,
      calc(100% - var(--notch)) 0,
      100% var(--notch),
      100% calc(100% - var(--notch)),
      calc(100% - var(--notch)) 100%,
      var(--notch) 100%,
      0 calc(100% - var(--notch)),
      0 var(--notch)
    );
    transition: transform 300ms ease; /* slide when groups toggle */
    will-change: transform;
}

/* Slide container slightly left when groups are active */
body.groups-active .container { transform: translateX(-16px); }

/* Disable holographic gradient border overlay */
.container::before { content: none; }

/* Disable corner brackets for a clean border-only look */
.container::after { content: none; }

label {
    font-size: 0.95em;
    color: var(--text);
    margin-top: 12px;
    display: block;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0.9;
}

input[type="number"],
input[type="text"] {
    width: 18ch;
    min-width: 10ch;
    max-width: 100%;
    padding: 12px 14px;
    margin: 10px 0 18px 0;
    border-radius: 10px;
    border: 1px solid rgba(0, 231, 255, 0.35);
    background: radial-gradient(180px 60px at 20% 0%, rgba(0, 231, 255, 0.08), transparent 60%) #0d1322;
    color: var(--text);
    font-size: 1.1em;
    caret-color: var(--neon);
    box-shadow:
      0 0 0 2px rgba(0, 231, 255, 0.06) inset,
      0 0 14px rgba(0, 231, 255, 0.15) inset,
      0 4px 14px rgba(0,0,0,0.4);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--neon);
    box-shadow:
      0 0 0 2px rgba(0, 231, 255, 0.12) inset,
      0 0 20px rgba(0, 231, 255, 0.35);
}

/* Narrow width for group size inputs (two digits) */
input.group-size {
    width: 6ch;
    min-width: 0;
}

button {
    background: linear-gradient(90deg, var(--neon), var(--magenta));
    color: #021014;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1em;
    font-family: 'Orbitron', 'Segoe UI', Arial, sans-serif;
    font-weight: 700;
    letter-spacing: 1px;
    box-shadow: 0 0 16px rgba(0, 231, 255, 0.35);
    margin-top: 8px;
    transition: transform 0.15s ease, box-shadow 0.25s ease;
}

button:hover { transform: translateY(-1px) scale(1.01); box-shadow: 0 0 22px rgba(0, 231, 255, 0.45); }

h2 {
    color: var(--amber);
    margin-top: 28px;
    text-shadow: 0 0 10px rgba(230, 196, 122, 0.45);
    font-size: 1.15em;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.results, .result { margin-top: 18px; }

/* Raise totals from container bottom by extra spacing */
#single-results { margin-bottom: 40px; }

.result, p {
    background: #0e1728; /* clean, solid for readability */
    border-left: 3px solid var(--amber);
    margin: 10px 0;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 1.05em;
    color: var(--text);
    letter-spacing: 1px;
}

.digital {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-variant-numeric: tabular-nums;
    color: var(--neon);
    font-weight: 700;
}

.credit {
    color: var(--amber);
    text-align: center;
    font-size: 1.05em;
    margin: 28px auto 32px;
    letter-spacing: 1.2px;
    opacity: 0.9;
    text-shadow: 0 0 10px rgba(230, 196, 122, 0.35);
}
/* Group results attached to the right of container */
#group-results {
    position: static;
    width: 0;                          /* take no horizontal space when hidden */
    flex: 0 0 0;
    max-height: calc(100vh - 90px);
    overflow: hidden;                  /* prevent brief scrollbar flash */
    -ms-overflow-style: none;          /* hide scrollbar on IE/Edge */
    scrollbar-width: none;             /* hide scrollbar on Firefox */
    padding: 4px 0;
    z-index: 1;
    margin-top: 50px; /* start just below container top (+42px) */
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 300ms ease, transform 300ms ease, width 300ms ease;
    pointer-events: none; /* non-interactive when hidden */
}

/* Reveal group list when active */
body.groups-active #group-results {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    width: 360px;                      /* expand to full width when active */
    flex: 0 0 360px;
    overflow: auto;                    /* enable scrolling when visible */
}

/* Hide WebKit scrollbars while keeping scroll functionality */
#group-results::-webkit-scrollbar { display: none; }

/* Stack on small screens */
@media (max-width: 980px) {
    .page-layout { flex-direction: column; align-items: stretch; gap: 8px; }
    /* Keep group-results collapsed when inactive on mobile */
    #group-results {
        position: static;
        width: auto;
        max-height: 0;
        margin: 0;
        overflow: hidden;
        transform: none;
    }
    /* Expand when active on mobile */
    body.groups-active #group-results {
        max-height: none;
        margin: 0 16px 24px;
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }
}

/* Group input rows (name + size) */
.group-input-row {
    display: grid;
    grid-template-columns: var(--group-label-w) var(--group-size-w) 1fr; /* Label | Size | Name */
    gap: 6px 6px; /* tighter spacing between label/inputs */
    align-items: center;
}
.group-input-row label { margin: 0; }
/* Remove vertical margins from inline inputs inside the row */
.group-input-row input[type="number"],
.group-input-row input[type="text"] { margin: 0; }

/* Ensure consistent widths within group rows */
.group-input-row .group-size { width: var(--group-size-w); min-width: var(--group-size-w); }
.group-input-row input[type="text"] { width: 100%; }

/* Animate group input rows when number of groups changes */
.group-input-row {
    opacity: 0;
    transform: translateY(var(--row-drop, 8px));
    will-change: opacity, transform;
}
.group-input-row.build-in { animation: group-build 250ms ease forwards; }

/* Copy button styling */
.group-copy-btn {
    margin-left: 8px;
    background: linear-gradient(90deg, var(--neon), var(--magenta));
    color: #021014;
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
}
.group-copy-btn:hover { filter: brightness(1.08); }
.toggle-row {
    display: flex;
    align-items: center;
    gap: 40px; /* spacing between mode text and discount toggle */
    flex-wrap: nowrap; /* keep on one line when possible */
    margin-bottom: 10px;
}
.toggle-row .toggle-wrapper { margin-bottom: 0; }
