/* ========================================================================
   AmpsToKVA — Premium Amps to KVA Converter
   Design System: Dark Electric · Glassmorphism · Amber/Teal
   Animation: Emil Kowalski design engineering philosophy
   ======================================================================== */

/* --- CSS Custom Properties --- */
:root {
    /* Brand Gradient — Electric Amber to Teal */
    --grad-start: #f1b84b;
    --grad-mid: #e0a13e;
    --grad-end: #f1b84b;
    --accent-1: #f1b84b;
    --accent-2: #55c9ae;
    --accent-3: #f1b84b;

    /* Surfaces */
    --bg-body: #080b0c;
    --bg-surface: #0d1112;
    --bg-card: #101516;
    --bg-card-hover: #13191a;
    --bg-input: #090d0e;
    --border-subtle: rgba(239, 235, 220, 0.11);
    --border-glow: rgba(241, 184, 75, 0.32);

    /* Text */
    --text-primary: #f4f1e8;
    --text-secondary: #b1b5b0;
    --text-tertiary: #8d958f;
    --text-accent: #f1b84b;

    /* Layout */
    --container-max: 1180px;
    --section-gap: 32px;
    --radius-sm: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 16px;

    /* Typography */
    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-body: 'Manrope', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

    /* Strong easing curves (Emil Kowalski) — never use browser defaults */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

    /* Duration scale — UI under 300ms */
    --dur-press: 120ms;
    --dur-fast: 150ms;
    --dur-normal: 200ms;
    --dur-medium: 250ms;
    --dur-slow: 400ms;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
    background-image:
        radial-gradient(circle at 12% 0%, rgba(241, 184, 75, 0.08), transparent 30rem),
        radial-gradient(circle at 88% 34%, rgba(85, 201, 174, 0.045), transparent 34rem);
}

main {
    position: relative;
    z-index: 1;
}

:focus-visible {
    outline: 2px solid var(--accent-1);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--text-primary);
    color: var(--bg-body);
    font-weight: 700;
    transform: translateY(-160%);
    transition: transform var(--dur-fast) var(--ease-out);
}

.skip-link:focus {
    transform: translateY(0);
}

::selection {
    background: rgba(245, 158, 11, 0.2);
    color: #fff;
}

a {
    color: var(--text-accent);
    text-decoration: none;
    transition: color var(--dur-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    a:hover { color: var(--accent-3); }
}

img { max-width: 100%; display: block; }

/* --- Ambient Background --- */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.09;
    will-change: transform;
    animation: orbFloat 24s ease-in-out infinite;
}

.orb-1 {
    width: 550px; height: 550px;
    background: radial-gradient(circle, var(--accent-1), transparent 70%);
    top: -12%; left: -6%;
    animation-duration: 22s;
}

.orb-2 {
    width: 450px; height: 450px;
    background: radial-gradient(circle, var(--accent-3), transparent 70%);
    bottom: 8%; right: -4%;
    animation-duration: 28s;
    animation-delay: -9s;
}

.orb-3 {
    width: 350px; height: 350px;
    background: radial-gradient(circle, var(--accent-2), transparent 70%);
    top: 45%; left: 35%;
    animation-duration: 32s;
    animation-delay: -15s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25%      { transform: translate(50px, -35px) scale(1.06); }
    50%      { transform: translate(-25px, 40px) scale(0.96); }
    75%      { transform: translate(-40px, -25px) scale(1.04); }
}

.grid-overlay {
    display: none;
}

/* Reduced motion: disable ambient orbs */
@media (prefers-reduced-motion: reduce) {
    .orb { animation: none; }
    .grid-overlay { display: none; }
}

/* --- Navigation --- */
.navbar {
    position: fixed;
    top: 14px; left: 14px; right: 14px;
    z-index: 1000;
    padding: 0;
}

.navbar.scrolled {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.nav-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 9px 12px 9px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    background: rgba(12, 16, 17, 0.78);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    backdrop-filter: blur(18px) saturate(1.15);
    -webkit-backdrop-filter: blur(18px) saturate(1.15);
    transition: background var(--dur-medium) var(--ease-out), border-color var(--dur-medium) var(--ease-out);
}

.navbar.scrolled .nav-container {
    background: rgba(8, 11, 12, 0.94);
    border-color: rgba(239, 235, 220, 0.16);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 32px; height: 32px;
    flex-shrink: 0;
}

.logo-icon svg { width: 100%; height: 100%; }

.logo-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.logo-accent {
    color: var(--accent-1);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 13px;
    border-radius: var(--radius-sm);
    transition:
        color var(--dur-fast) var(--ease-out),
        background var(--dur-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .nav-link:hover {
        color: var(--text-primary);
        background: rgba(255, 255, 255, 0.04);
    }
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}

.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: transform var(--dur-normal) var(--ease-out), opacity var(--dur-normal) var(--ease-out);
}

.mobile-menu-btn.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.mobile-menu-btn.open span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* --- Container --- */
.section-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 32px;
}

/* --- Section Headers --- */
.section-header {
    text-align: left;
    margin-bottom: 52px;
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3.2rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
    text-wrap: balance;
}

.gradient-text {
    color: var(--accent-1);
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 66ch;
    margin: 0;
    line-height: 1.7;
    text-wrap: pretty;
}

.content-section .section-header,
.faq-section .section-header {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
    align-items: end;
    gap: 48px;
}

.content-section .section-header .section-title,
.faq-section .section-header .section-title {
    margin-bottom: 0;
}

/* ========================================================================
   STAGGER ANIMATIONS — elements fade in on page load
   ======================================================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calc-card,
.result-container {
    opacity: 0;
    animation: fadeInUp 500ms var(--ease-out) forwards;
}

.calc-card { animation-delay: 0ms; }
.result-container { animation-delay: 80ms; }

.content-step-card {
    opacity: 0;
    animation: fadeInUp 400ms var(--ease-out) forwards;
}
.content-step-card:nth-child(1) { animation-delay: 0ms; }
.content-step-card:nth-child(2) { animation-delay: 50ms; }
.content-step-card:nth-child(3) { animation-delay: 100ms; }

@media (prefers-reduced-motion: reduce) {
    .calc-card,
    .result-container,
    .content-step-card {
        opacity: 1;
        animation: none;
    }
}

/* ========================================================================
   CALCULATOR SECTION
   ======================================================================== */
.calculator-section {
    padding: 158px 0 108px;
}

.calculator-section .section-header {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(20rem, 0.65fr);
    align-items: end;
    gap: 64px;
    margin-bottom: 64px;
}

.calculator-section .section-title {
    max-width: 13ch;
    margin: 0;
    font-size: clamp(3.6rem, 7.4vw, 5.7rem);
    line-height: 0.92;
    letter-spacing: -0.04em;
}

.calculator-section .section-title > strong {
    display: block;
    font-weight: 700;
}

.calculator-section .section-subtitle {
    padding-bottom: 5px;
    font-size: 1.02rem;
}

.calculator-layout {
    display: grid;
    grid-template-columns: minmax(19rem, 0.82fr) minmax(0, 1.18fr);
    gap: 16px;
    align-items: start;
}

/* --- Calculator Card --- */
.calc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 30px;
    transition: border-color var(--dur-normal) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .calc-card:hover {
        border-color: var(--border-glow);
    }
}

.calc-card-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 22px;
    color: var(--text-primary);
}

/* --- Form Controls --- */
.converter-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--accent-2);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-2);
    animation: livePulse 2.5s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.35); }
    50%      { opacity: 0.5; box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .live-dot { animation: none; }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0;
}

.form-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.form-input {
    width: 100%;
    min-height: 52px;
    padding: 13px 50px 13px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-mono);
    outline: none;
    transition:
        border-color var(--dur-fast) var(--ease-out),
        box-shadow var(--dur-fast) var(--ease-out);
}

.form-input::placeholder { color: var(--text-tertiary); opacity: 1; }

.form-input:focus {
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08);
}

.form-input[aria-invalid="true"] {
    border-color: #dc7a68;
    box-shadow: 0 0 0 3px rgba(220, 122, 104, 0.12);
}

.form-unit {
    position: absolute;
    right: 14px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-tertiary);
    pointer-events: none;
}

.form-select {
    width: 100%;
    padding: 13px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-body);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23586174' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition:
        border-color var(--dur-fast) var(--ease-out),
        box-shadow var(--dur-fast) var(--ease-out);
}

.form-select:focus {
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08);
}

.form-select option {
    background: #0a0f1c;
    color: var(--text-primary);
}

/* --- Phase Toggle — slider-based segmented control --- */
.phase-toggle {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.phase-toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: rgba(241, 184, 75, 0.14);
    border: 1px solid rgba(241, 184, 75, 0.25);
    border-radius: 9px;
    transition: transform var(--dur-normal) var(--ease-out);
    z-index: 0;
}

.phase-toggle-slider.right {
    transform: translateX(100%);
}

.phase-btn {
    flex: 1;
    padding: 11px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease-out);
    position: relative;
    z-index: 1;
}

/* Button press feedback — every pressable element (Emil principle) */
.phase-btn:active {
    transform: scale(0.97);
}

.phase-btn.active {
    color: var(--accent-1);
}

@media (hover: hover) and (pointer: fine) {
    .phase-btn:hover:not(.active) {
        color: var(--text-secondary);
    }
}

/* --- Action Buttons --- */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.btn-calculate {
    flex: 1;
    padding: 13px 24px;
    background: var(--accent-1);
    border: none;
    border-radius: var(--radius-sm);
    color: #151109;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: var(--font-display);
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: transform var(--dur-press) var(--ease-out), background var(--dur-fast) var(--ease-out), box-shadow var(--dur-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
}

/* Button press — scale down for feedback (Emil: 0.95-0.98) */
.btn-calculate:active {
    transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
    .btn-calculate:hover {
        background: #f5c663;
        box-shadow: 0 8px 24px rgba(80, 55, 12, 0.34);
    }
}

.btn-reset {
    padding: 13px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition:
        transform var(--dur-press) var(--ease-out),
        background var(--dur-fast) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out);
}

.btn-reset:active {
    transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
    .btn-reset:hover {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* --- Result Panel --- */
.result-container {
    background:
        radial-gradient(circle at 72% 8%, rgba(241, 184, 75, 0.1), transparent 18rem),
        #111615;
    border: 1px solid rgba(241, 184, 75, 0.19);
    border-radius: var(--radius-lg);
    padding: 30px;
    position: sticky;
    top: 90px;
    transition: border-color var(--dur-normal) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .result-container:hover {
        border-color: var(--border-glow);
    }
}

.result-display {
    text-align: left;
    padding: 28px 0 26px;
}

.result-big {
    font-family: var(--font-display);
    font-size: clamp(3.5rem, 8vw, 6rem);
    font-weight: 700;
    color: var(--accent-1);
    line-height: 0.95;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    /* Animate opacity only — transform + opacity are GPU-cheap (Emil principle) */
    transition: opacity var(--dur-fast) var(--ease-out);
}

.result-label-text {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-top: 8px;
    font-family: var(--font-mono);
}

.result-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-subtle), transparent);
    margin: 18px 0;
}

/* --- Formula Card inside Result --- */
.result-formula-card {
    background: rgba(0, 0, 0, 0.13);
    border: 1px solid rgba(239, 235, 220, 0.08);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 18px;
}

.result-formula-title {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.formula-line {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 3px 0;
    border-left: 1px solid rgba(239, 235, 220, 0.12);
    padding-left: 12px;
    margin-bottom: 3px;
}

.formula-line strong {
    color: var(--accent-1);
}

/* --- Result Extras Grid --- */
.result-extras {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.result-extra-item {
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(239, 235, 220, 0.07);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
    transition: border-color var(--dur-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .result-extra-item:hover {
        border-color: rgba(245, 158, 11, 0.12);
    }
}

.extra-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 4px;
}

.extra-value {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}

.result-assumption-note {
    margin: 10px 2px 0;
    color: var(--text-tertiary);
    font-size: 0.72rem;
    line-height: 1.45;
    text-align: center;
}

/* --- Voltage Type Badge --- */
.voltage-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.12);
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-2);
    margin-top: 10px;
}

.voltage-type-badge svg {
    width: 11px;
    height: 11px;
}

/* ========================================================================
   ANIMATED POWER FLOW (unique to this tool)
   ======================================================================== */
.arc-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    padding: 16px 0;
    position: relative;
}

.arc-node {
    width: 60px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.arc-node-amps {
    background: rgba(245, 158, 11, 0.08);
    border: 1.5px solid rgba(245, 158, 11, 0.2);
    color: var(--accent-1);
}

.arc-node-kva {
    background: rgba(6, 182, 212, 0.08);
    border: 1.5px solid rgba(6, 182, 212, 0.2);
    color: var(--accent-3);
}

.arc-flow {
    display: flex;
    align-items: center;
    gap: 5px;
}

.arc-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent-2);
    opacity: 0.55;
}

.arc-dot:nth-child(2) { opacity: 0.62; }
.arc-dot:nth-child(3) { opacity: 0.7; }
.arc-dot:nth-child(4) { opacity: 0.8; }
.arc-dot:nth-child(5) { opacity: 0.92; }

@keyframes arcFlow {
    0%, 100% { opacity: 0.15; transform: scale(0.7); }
    50%      { opacity: 1; transform: scale(1.2); }
}

@media (prefers-reduced-motion: reduce) {
    .arc-dot { animation: none; opacity: 0.5; }
}

/* ========================================================================
   SUB CALCULATOR DIRECTORY
   ======================================================================== */
.subcalculator-directory {
    padding: 8px 0 104px;
}

.subcalculator-directory-header {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
    align-items: end;
    gap: 48px;
    margin-bottom: 38px;
}

.subcalculator-directory-header h2 {
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3.2rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.subcalculator-directory-header p {
    max-width: 52ch;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

.subcalculator-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 30px;
}

.subcalculator-links a {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px 2px;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.subcalculator-links a:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--border-subtle);
}

.subcalculator-links a > span {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
}

.subcalculator-links strong {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
}

.subcalculator-links small {
    color: var(--text-tertiary);
    font-size: 0.78rem;
    line-height: 1.55;
    text-wrap: pretty;
}

.subcalculator-links svg {
    width: 21px;
    height: 21px;
    flex: 0 0 auto;
    color: var(--accent-1);
    transition: transform var(--dur-fast) var(--ease-out);
}

/* ========================================================================
   EXPLANATORY DIAGRAMS
   ======================================================================== */
.section-diagram {
    margin: 0 0 46px;
    padding: 28px 0 20px;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.section-header + .section-diagram {
    margin-top: -20px;
}

.subcalculator-directory-header + .section-diagram {
    margin-top: -8px;
}

.content-card > .section-diagram {
    margin: 24px 0 26px;
}

.diagram-flow {
    display: flex;
    align-items: stretch;
}

.diagram-node,
.diagram-option,
.diagram-branch-root,
.diagram-branch-option {
    min-width: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.018);
}

.diagram-node {
    display: grid;
    flex: 1 1 0;
    min-height: 118px;
    align-content: center;
    padding: 18px;
}

.diagram-node--result {
    border-color: rgba(241, 184, 75, 0.28);
    background: rgba(241, 184, 75, 0.055);
}

.diagram-node-symbol,
.diagram-option > span,
.diagram-branch-root > span {
    color: var(--accent-1);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.diagram-node strong,
.diagram-option strong,
.diagram-branch-root strong,
.diagram-branch-option strong {
    margin-top: 7px;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 0.9rem;
    line-height: 1.3;
}

.diagram-node small,
.diagram-option small,
.diagram-branch-root small,
.diagram-branch-option small {
    margin-top: 5px;
    color: var(--text-tertiary);
    font-size: 0.73rem;
    line-height: 1.45;
}

.diagram-connector {
    display: flex;
    width: 68px;
    flex: 0 0 68px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-align: center;
}

.diagram-connector-line {
    position: relative;
    display: block;
    width: 100%;
    height: 1px;
    background: rgba(241, 184, 75, 0.36);
}

.diagram-connector-line::after {
    position: absolute;
    top: -3px;
    right: 0;
    width: 7px;
    height: 7px;
    border-top: 1px solid var(--accent-1);
    border-right: 1px solid var(--accent-1);
    content: '';
    transform: rotate(45deg);
}

.diagram-option-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.diagram-option {
    display: flex;
    min-height: 118px;
    flex-direction: column;
    justify-content: center;
    padding: 18px;
}

.diagram-branch-root {
    display: grid;
    width: min(380px, 100%);
    min-height: 104px;
    margin: 0 auto;
    align-content: center;
    padding: 18px 22px;
    text-align: center;
}

.diagram-branch-options {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    padding-top: 40px;
}

.diagram-branch-options::before {
    position: absolute;
    top: 20px;
    right: 16.667%;
    left: 16.667%;
    height: 1px;
    background: rgba(241, 184, 75, 0.36);
    content: '';
}

.diagram-branch-option {
    position: relative;
    display: grid;
    min-height: 126px;
    align-content: center;
    padding: 18px;
    text-align: center;
}

.diagram-branch-option::before {
    position: absolute;
    bottom: 100%;
    left: 50%;
    width: 1px;
    height: 20px;
    background: rgba(241, 184, 75, 0.36);
    content: '';
}

.diagram-branch-option code {
    margin-top: 8px;
    color: var(--accent-1);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.diagram-power-layout {
    display: grid;
    grid-template-columns: minmax(18rem, 0.7fr) minmax(0, 1.3fr);
    align-items: center;
    gap: 52px;
}

.diagram-power-triangle {
    display: block;
    width: min(100%, 340px);
    height: auto;
    margin: 0 auto;
}

.diagram-triangle-fill {
    fill: rgba(85, 201, 174, 0.035);
}

.diagram-triangle-line,
.diagram-right-angle {
    fill: none;
    stroke: rgba(241, 184, 75, 0.66);
    stroke-width: 1.5;
}

.diagram-svg-label,
.diagram-svg-accent {
    fill: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
}

.diagram-svg-accent {
    fill: var(--accent-1);
}

.diagram-power-notes {
    display: grid;
    gap: 0;
}

.diagram-power-notes > div {
    display: grid;
    gap: 5px;
    padding: 19px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.diagram-power-notes > div:first-child {
    border-top: 1px solid var(--border-subtle);
}

.diagram-power-notes strong {
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 0.95rem;
}

.diagram-power-notes span {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    line-height: 1.55;
}

.section-diagram figcaption {
    display: grid;
    grid-template-columns: minmax(14rem, 0.65fr) minmax(0, 1.35fr);
    gap: 28px;
    margin-top: 20px;
    color: var(--text-tertiary);
    font-size: 0.78rem;
    line-height: 1.55;
}

.section-diagram figcaption strong {
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.82rem;
}

@media (hover: hover) and (pointer: fine) {
    .subcalculator-links a:hover svg {
        transform: translateX(4px);
    }
}

/* ========================================================================
   CONTENT SECTIONS
   ======================================================================== */
.content-section {
    padding: 104px 0;
}

#converter,
#subcalculators,
#how-to-calculate-amps-to-kva,
#amps-to-kva-formula,
#amps-to-kva-excel-formula,
#amps-to-kva-conversion-chart,
#kva-to-amps,
#what-is-kva-in-amps,
#faq {
    scroll-margin-top: 88px;
}

/* --- Content Cards --- */
.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: border-color var(--dur-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .content-card:hover {
        border-color: var(--border-glow);
    }
}

.content-card .content-card-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text-primary);
    line-height: 1.7;
}

.content-card p {
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: 10px;
    font-size: 0.92rem;
}

.content-card p:last-child { margin-bottom: 0; }

.content-note {
    border-left: 1px solid var(--accent-1);
    background: rgba(241, 184, 75, 0.045);
}

/* --- Steps Grid --- */
.content-steps-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 28px;
    margin-bottom: 40px;
}

.content-step-card {
    background: transparent;
    border: 0;
    border-top: 1px solid var(--border-subtle);
    border-radius: 0;
    padding: 24px 12px 0 0;
    position: relative;
    /* Hover: only transform + border — GPU-safe */
    transition:
        border-color var(--dur-fast) var(--ease-out),
        transform var(--dur-normal) var(--ease-out);
}

.content-step-card:nth-child(1) { grid-column: span 5; }
.content-step-card:nth-child(2) { grid-column: span 4; }
.content-step-card:nth-child(3) { grid-column: span 3; }

@media (hover: hover) and (pointer: fine) {
    .content-step-card:hover {
        border-color: var(--accent-1);
        transform: translateY(-2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .content-step-card:hover {
        transform: none;
    }
}

.step-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 8px;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-1);
    margin-bottom: 14px;
}

.content-step-card .content-step-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
    line-height: 1.7;
}

.content-step-card p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.7;
}

/* --- Content Lists --- */
.content-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.content-list li {
    position: relative;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.65;
}

.content-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 9px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-1);
}

.content-list li strong {
    color: var(--text-primary);
}

/* --- Formula Section --- */
.formula-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 0.75fr);
    gap: 16px;
}

.formula-display {
    background: rgba(241, 184, 75, 0.045);
    border: 1px solid rgba(241, 184, 75, 0.12);
    border-radius: var(--radius-md);
    padding: 18px;
    margin: 14px 0;
    text-align: center;
}

.formula-equation {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent-1);
    letter-spacing: 0.01em;
}

.content-card .formula-sub-heading {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    margin-top: 22px;
    margin-bottom: 6px;
    color: var(--text-primary);
    line-height: 1.7;
}

.formula-example {
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(239, 235, 220, 0.07);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
}

.formula-example .formula-example-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-accent);
    margin-bottom: 6px;
    line-height: 1.7;
}

.formula-example code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.formula-example code strong {
    color: var(--accent-1);
}

.formula-note {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    font-style: italic;
    margin-top: 6px;
}

/* --- Tables --- */
.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-header {
    padding: 22px 24px 0;
}

.table-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.7;
}

.conversion-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 14px;
}

.conversion-table th {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.conversion-table td {
    padding: 10px 18px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    font-variant-numeric: tabular-nums;
}

.conversion-table tbody tr {
    transition: background var(--dur-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .conversion-table tbody tr:hover td {
        background: rgba(245, 158, 11, 0.02);
    }
}

.conversion-table .mono {
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.conversion-table th:first-child,
.conversion-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #101516;
}

/* --- FAQ Section --- */
.faq-section {
    padding: 104px 0 124px;
}

.faq-grid {
    max-width: 820px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.faq-section .section-header {
    display: block;
}

.faq-item {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 0;
    overflow: hidden;
    transition: border-color var(--dur-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .faq-item:hover {
        border-color: var(--accent-1);
    }
}

.faq-question {
    width: 100%;
    padding: 20px 0;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    font-family: var(--font-body);
    transition: transform var(--dur-press) var(--ease-out);
}

.faq-question:active {
    transform: scale(0.99);
}

.faq-chevron {
    flex-shrink: 0;
    transition: transform var(--dur-normal) var(--ease-out);
    color: var(--text-tertiary);
}

.faq-item.open .faq-chevron {
    transform: rotate(180deg);
    color: var(--accent-1);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--dur-slow) var(--ease-out);
}

.faq-item.open .faq-answer {
    max-height: 400px;
}

.faq-answer p {
    color: var(--text-secondary);
    line-height: 1.75;
    font-size: 0.9rem;
    padding: 0 48px 22px 0;
}

/* --- Footer --- */
.site-footer {
    padding: 40px 0 28px;
    border-top: 1px solid var(--border-subtle);
}

.footer-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.footer-copy {
    font-size: 0.82rem;
    color: var(--text-tertiary);
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-link {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    transition: color var(--dur-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .footer-link:hover {
        color: var(--text-accent);
    }
}

/* --- Back to Top --- */
.back-to-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Enter: ease-out, Exit: fast (asymmetric timing — Emil) */
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.95);
    transition:
        opacity var(--dur-normal) var(--ease-out),
        visibility var(--dur-normal) var(--ease-out),
        transform var(--dur-normal) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out);
    z-index: 999;
    backdrop-filter: blur(12px);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.back-to-top:active {
    transform: scale(0.93);
}

@media (hover: hover) and (pointer: fine) {
    .back-to-top:hover {
        border-color: var(--accent-1);
        color: var(--accent-1);
    }
}

/* --- Content Utility --- */
.content-list {
    padding-left: 20px;
    color: var(--text-secondary);
}

.content-list li {
    margin-bottom: 10px;
    line-height: 1.7;
    font-size: 0.9rem;
}

.content-list li strong {
    color: var(--text-primary);
}

.content-examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 28px;
}

/* ========================================================================
   RESPONSIVE
   ======================================================================== */
@media (max-width: 900px) {
    .calculator-section .section-header,
    .content-section .section-header,
    .faq-section .section-header {
        display: block;
    }
    .calculator-section .section-title {
        margin-bottom: 24px;
    }
    .calculator-layout {
        grid-template-columns: 1fr;
    }
    .result-container {
        position: static;
    }
    .formula-grid {
        grid-template-columns: 1fr;
    }
    .content-steps-grid {
        grid-template-columns: 1fr;
    }
    .content-step-card:nth-child(1),
    .content-step-card:nth-child(2),
    .content-step-card:nth-child(3) {
        grid-column: auto;
    }
    .subcalculator-directory-header {
        display: block;
    }
    .subcalculator-directory-header h2 {
        margin-bottom: 16px;
    }
    .diagram-option-grid {
        grid-template-columns: 1fr 1fr;
    }
    .diagram-power-layout {
        grid-template-columns: 1fr;
        gap: 18px;
    }
    .nav-links {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        right: 0;
        background: rgba(8, 11, 12, 0.98);
        backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-md);
    }
    .nav-links.open {
        display: flex;
    }
    .mobile-menu-btn {
        display: flex;
    }
}

@media (max-width: 600px) {
    .section-container {
        padding: 0 18px;
    }
    .calc-card, .result-container {
        padding: 22px 20px;
    }
    .calculator-section {
        padding: 116px 0 64px;
    }
    .calculator-section .section-header {
        margin-bottom: 40px;
    }
    .calculator-section .section-title {
        font-size: clamp(2.7rem, 13vw, 4.3rem);
    }
    .content-section,
    .faq-section {
        padding: 76px 0;
    }
    .subcalculator-directory {
        padding: 6px 0 76px;
    }
    .subcalculator-links {
        grid-template-columns: 1fr;
    }
    .section-diagram {
        margin-bottom: 36px;
        padding: 22px 0 18px;
    }
    .section-header + .section-diagram {
        margin-top: -18px;
    }
    .diagram-flow {
        flex-direction: column;
    }
    .diagram-node {
        width: 100%;
        min-height: 96px;
    }
    .diagram-connector {
        width: 100%;
        height: 48px;
        flex: 0 0 48px;
        flex-direction: row;
    }
    .diagram-connector-line {
        width: 1px;
        height: 32px;
    }
    .diagram-connector-line::after {
        top: auto;
        right: -3px;
        bottom: 0;
        transform: rotate(135deg);
    }
    .diagram-option-grid,
    .diagram-branch-options {
        grid-template-columns: 1fr;
    }
    .diagram-option {
        min-height: 100px;
    }
    .diagram-branch-options {
        gap: 12px;
        padding-top: 24px;
    }
    .diagram-branch-options::before {
        top: 0;
        right: auto;
        left: 50%;
        width: 1px;
        height: 24px;
    }
    .diagram-branch-option {
        min-height: 108px;
    }
    .diagram-branch-option::before {
        display: none;
    }
    .section-diagram figcaption {
        grid-template-columns: 1fr;
        gap: 7px;
    }
    .subcalculator-links a:nth-last-child(-n + 2) {
        border-bottom: 0;
    }
    .subcalculator-links a:last-child {
        border-bottom: 1px solid var(--border-subtle);
    }
    .result-extras {
        grid-template-columns: 1fr 1fr;
    }
    .content-steps-grid {
        grid-template-columns: 1fr;
    }
    .phase-btn {
        font-size: 0.78rem;
        padding: 10px 10px;
    }
    .footer-container {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 420px) {
    .form-actions {
        flex-direction: column;
    }
    .btn-reset {
        min-height: 46px;
    }
    .result-extras {
        grid-template-columns: 1fr;
    }
}
