/* ==========================================================================
   JV Calculator — Liquid Glass design system
   ========================================================================== */

:root {
    --env-base: #050a0c;
    --env-deep: #071114;
    --text-primary: rgba(255, 255, 255, 0.96);
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.48);
    --line-soft: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.16);
    --gold: #d9b25a;
    --gold-soft: rgba(217, 178, 90, 0.55);
    --ease-glass: cubic-bezier(0.33, 1, 0.68, 1);
}

html {
    background: var(--env-base);
}

body.app-body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--env-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Immersive cover layer
   -------------------------------------------------------------------------- */

.cover-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 75% 10%, #12333a 0%, transparent 55%),
        radial-gradient(110% 100% at 15% 90%, #1a2c24 0%, transparent 60%),
        linear-gradient(165deg, #0c1a1e 0%, #050a0c 70%);
}

.cover-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transform: scale(1.04);
    transition: opacity 550ms var(--ease-glass), transform 1600ms var(--ease-glass);
    will-change: opacity;
}

.cover-image.is-visible {
    opacity: 1;
    transform: scale(1);
}

.cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(5, 10, 12, 0.18),
        rgba(5, 10, 12, 0.3) 45%,
        rgba(5, 10, 12, 0.62)
    );
    transition: background-color 450ms var(--ease-glass), backdrop-filter 450ms var(--ease-glass);
}

/* Views that need calmer backgrounds dim the scenery further */
body[data-active-view='project-builder'] .cover-overlay,
body[data-active-view='locations'] .cover-overlay,
body[data-active-view='unit-types'] .cover-overlay,
body[data-active-view='foundation-rules'] .cover-overlay {
    background: linear-gradient(
        to bottom,
        rgba(5, 10, 12, 0.72),
        rgba(5, 10, 12, 0.8) 45%,
        rgba(5, 10, 12, 0.9)
    );
}

body[data-active-view='project-detail'] .cover-overlay {
    background: linear-gradient(
        to bottom,
        rgba(5, 10, 12, 0.6),
        rgba(5, 10, 12, 0.72) 45%,
        rgba(5, 10, 12, 0.88)
    );
}

/* --------------------------------------------------------------------------
   Glass primitives
   -------------------------------------------------------------------------- */

.glass-panel {
    background: linear-gradient(145deg, rgba(16, 26, 28, 0.72), rgba(7, 13, 15, 0.56));
    border: 1px solid var(--line-soft);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 20px 50px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(28px) saturate(135%);
    -webkit-backdrop-filter: blur(28px) saturate(135%);
    border-radius: 28px;
}

.glass-card {
    background: linear-gradient(150deg, rgba(20, 32, 33, 0.58), rgba(9, 16, 18, 0.44));
    border: 1px solid var(--line-soft);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        0 14px 40px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(20px) saturate(130%);
    -webkit-backdrop-filter: blur(20px) saturate(130%);
    border-radius: 22px;
    transition: background 250ms var(--ease-glass), border-color 250ms var(--ease-glass),
        transform 250ms var(--ease-glass), box-shadow 250ms var(--ease-glass);
}

.glass-card-subtle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    border-radius: 18px;
}

.glass-control {
    background: rgba(10, 18, 20, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
    border-radius: 14px;
    color: var(--text-primary);
    transition: background 200ms var(--ease-glass), border-color 200ms var(--ease-glass);
}

.glass-control:hover {
    background: rgba(20, 32, 34, 0.55);
    border-color: rgba(255, 255, 255, 0.2);
}

.glass-control:focus,
.glass-control:focus-within {
    outline: none;
    border-color: var(--gold-soft);
    background: rgba(20, 32, 34, 0.6);
}

.glass-sidebar {
    background: linear-gradient(170deg, rgba(16, 26, 27, 0.62), rgba(7, 13, 15, 0.5));
    border: 1px solid rgba(255, 255, 255, 0.11);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.09),
        0 24px 60px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(28px) saturate(140%);
    -webkit-backdrop-filter: blur(28px) saturate(140%);
    border-radius: 26px;
}

.glass-overlay {
    background: rgba(4, 8, 10, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* --------------------------------------------------------------------------
   Buttons + pills
   -------------------------------------------------------------------------- */

.glass-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
    font-weight: 600;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: background 200ms var(--ease-glass), border-color 200ms var(--ease-glass),
        transform 200ms var(--ease-glass);
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.13);
    border-color: rgba(255, 255, 255, 0.24);
}

.glass-btn:active {
    transform: scale(0.98);
}

.glass-btn-gold {
    background: linear-gradient(140deg, rgba(217, 178, 90, 0.24), rgba(217, 178, 90, 0.1));
    border-color: rgba(217, 178, 90, 0.4);
    color: #f2dda8;
}

.glass-btn-gold:hover {
    background: linear-gradient(140deg, rgba(217, 178, 90, 0.34), rgba(217, 178, 90, 0.16));
    border-color: rgba(217, 178, 90, 0.55);
}

.glass-btn-danger {
    border-color: rgba(248, 113, 113, 0.35);
    color: #fca5a5;
}

.glass-btn-danger:hover {
    background: rgba(248, 113, 113, 0.14);
    border-color: rgba(248, 113, 113, 0.5);
}

.nav-pill {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.66rem 0.9rem;
    border-radius: 14px;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 200ms var(--ease-glass), color 200ms var(--ease-glass),
        border-color 200ms var(--ease-glass);
}

.nav-pill:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
}

.nav-pill.is-active {
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
    border-color: rgba(217, 178, 90, 0.35);
    color: var(--text-primary);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.nav-pill svg {
    width: 1.1rem;
    height: 1.1rem;
    flex: none;
    opacity: 0.8;
}

/* --------------------------------------------------------------------------
   Metric tint variants (translucent gradients over glass)
   -------------------------------------------------------------------------- */

.tint-value    { background: linear-gradient(150deg, rgba(38, 118, 86, 0.5),  rgba(14, 42, 32, 0.34)); }
.tint-cost     { background: linear-gradient(150deg, rgba(158, 94, 38, 0.48), rgba(56, 32, 12, 0.32)); }
.tint-profit   { background: linear-gradient(150deg, rgba(46, 92, 158, 0.48), rgba(16, 32, 58, 0.32)); }
.tint-projects { background: linear-gradient(150deg, rgba(104, 70, 170, 0.48), rgba(36, 24, 62, 0.32)); }
.tint-roi      { background: linear-gradient(150deg, rgba(34, 122, 138, 0.48), rgba(12, 42, 48, 0.32)); }
.tint-margin   { background: linear-gradient(150deg, rgba(148, 118, 44, 0.48), rgba(52, 40, 14, 0.32)); }

/* --------------------------------------------------------------------------
   Forms (dark translucent controls)
   -------------------------------------------------------------------------- */

.field-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.field-input {
    width: 100%;
    padding: 0.55rem 0.8rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: rgba(10, 18, 20, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    transition: border-color 200ms var(--ease-glass), background 200ms var(--ease-glass);
}

.field-input::placeholder {
    color: var(--text-muted);
}

.field-input:focus {
    outline: none;
    border-color: var(--gold-soft);
    background: rgba(16, 26, 28, 0.6);
}

select.field-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='rgba(255,255,255,0.55)' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2.2rem;
}

select.field-input option {
    background: #0d1a1d;
    color: #f1f5f4;
}

/* --------------------------------------------------------------------------
   Tables (dark glass)
   -------------------------------------------------------------------------- */

.glass-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}

.glass-table thead th {
    text-align: left;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
}

.glass-table tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.glass-table tbody tr:last-child td {
    border-bottom: none;
}

.glass-table tbody tr {
    transition: background 180ms var(--ease-glass);
}

.glass-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* --------------------------------------------------------------------------
   Project carousel
   -------------------------------------------------------------------------- */

.carousel-track {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 0.25rem;
    padding: 0.4rem 0.25rem 0.6rem;
    scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
    display: none;
}

.project-card {
    flex: none;
    width: 300px;
    scroll-snap-align: start;
    cursor: pointer;
    overflow: hidden;
    text-align: left;
    padding: 0;
}

.project-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 22px 50px rgba(0, 0, 0, 0.38);
}

.project-card.is-active {
    border-color: rgba(217, 178, 90, 0.6);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 0 1px rgba(217, 178, 90, 0.35),
        0 22px 50px rgba(0, 0, 0, 0.4);
}

.project-card-thumb {
    position: relative;
    height: 96px;
    overflow: hidden;
    background: linear-gradient(150deg, #14262b, #0a1417);
}

.project-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 400ms var(--ease-glass);
}

.project-card:hover .project-card-thumb img {
    transform: scale(1.05);
}

/* --------------------------------------------------------------------------
   Overview panel transitions
   -------------------------------------------------------------------------- */

.overview-panel {
    transition: opacity 320ms var(--ease-glass), transform 320ms var(--ease-glass);
}

.overview-panel.is-entering {
    opacity: 0;
    transform: translateX(20px);
}

/* --------------------------------------------------------------------------
   Progress
   -------------------------------------------------------------------------- */

.progress-track {
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #2fbf9a, #7ee0c3);
    transition: width 500ms var(--ease-glass);
}

.progress-ring {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    font-size: 0.68rem;
    font-weight: 700;
    color: #b6f0dd;
    background:
        radial-gradient(closest-side, rgba(7, 14, 16, 0.85) 78%, transparent 79% 100%),
        conic-gradient(#2fbf9a calc(var(--progress) * 1%), rgba(255, 255, 255, 0.14) 0);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-secondary);
}

.badge-teal {
    background: rgba(45, 191, 154, 0.14);
    border-color: rgba(45, 191, 154, 0.35);
    color: #8fe6cc;
}

.badge-gold {
    background: rgba(217, 178, 90, 0.14);
    border-color: rgba(217, 178, 90, 0.4);
    color: #ecd49a;
}

.badge-muted {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.badge-amber {
    background: rgba(245, 158, 11, 0.13);
    border-color: rgba(245, 158, 11, 0.35);
    color: #fbd38d;
}

/* --------------------------------------------------------------------------
   Scroll + toast + misc
   -------------------------------------------------------------------------- */

.scroll-x {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.scroll-x::-webkit-scrollbar {
    height: 6px;
}

.scroll-x::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}

.toast {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translate(-50%, -12px);
    z-index: 80;
    opacity: 0;
    pointer-events: none;
    transition: opacity 260ms var(--ease-glass), transform 260ms var(--ease-glass);
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.view {
    animation: view-in 320ms var(--ease-glass);
}

@keyframes view-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-cover {
    position: relative;
    overflow: hidden;
    border-radius: 28px;
    background: linear-gradient(150deg, #14262b, #0a1417);
}

.hero-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-cover .hero-shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(5, 10, 12, 0.2),
        rgba(5, 10, 12, 0.35) 55%,
        rgba(5, 10, 12, 0.72)
    );
}

.unit-glyph {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(150deg, rgba(217, 178, 90, 0.16), rgba(217, 178, 90, 0.05));
    border: 1px solid rgba(217, 178, 90, 0.25);
    color: #ecd49a;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
