/* ============================================================
   ROI Calculator — design tokens
   ============================================================ */
:root {
    --color-bg: #EEF3EF;
    --color-surface: #FFFFFF;
    --color-surface-tint: #F5F8F5;
    --color-primary: #0B3D2E;
    --color-primary-light: #145C41;
    --color-accent: #16A34A;
    --color-accent-soft: #DCF3E4;
    --color-negative: #C0392B;
    --color-negative-soft: #FBE7E4;
    --color-ink: #10231C;
    --color-muted: #5B6B63;
    --color-border: #DDE6DF;

    --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;

    --shadow-card: 0 20px 50px -20px rgba(11, 61, 46, 0.25);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background:
        radial-gradient(circle at 12% -10%, rgba(22, 163, 74, 0.10), transparent 45%),
        var(--color-bg);
    color: var(--color-ink);
    /* Fallback for browsers without svh support (older Safari/Firefox/Android WebView),
       then upgrade to the dynamic-toolbar-aware unit where available. */
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   Site masthead
   ============================================================ */
.site-header {
    background: linear-gradient(120deg, #0B1830 0%, #16294A 55%, #1B3358 100%);
}

.site-header-inner {
    display: flex;
    align-items: center;
    gap: 18px;
    max-width: 960px;
    margin: 0 auto;
    padding: clamp(16px, 3.5vw, 24px) clamp(16px, 4vw, 24px);
    /* Respect notches/rounded corners on modern phones in landscape */
    padding-left: max(clamp(16px, 4vw, 24px), env(safe-area-inset-left));
    padding-right: max(clamp(16px, 4vw, 24px), env(safe-area-inset-right));
}

.site-header-icon {
    flex: 0 0 auto;
    width: 70px;
    height: 70px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-header-icon img {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
}

.site-header-icon svg {
    width: 28px;
    height: 28px;
}

.site-header-text h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(20px, 2.6vw, 28px);
    color: #fff;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}

.site-header-text p {
    margin: 0;
    font-size: clamp(12.5px, 1.6vw, 14px);
    color: rgba(255, 255, 255, 0.68);
    max-width: 55ch;
}

.page-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vw, 48px);
}

/* ============================================================
   Site footer
   ============================================================ */
.site-footer {
    padding: 18px clamp(20px, 5vw, 56px) 28px;
    text-align: center;
}

.site-footer p {
    margin: 0;
    max-width: 900px;
    margin-inline: auto;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--color-muted);
}

@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;
    }
}

/* ============================================================
   Layout shell
   ============================================================ */
.calculator {
    width: 100%;
    max-width: 960px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.panel {
    padding: clamp(24px, 3.5vw, 44px);
}

.panel--inputs {
    background: var(--color-surface);
}

.panel--results {
    background: var(--color-primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(18px, 2.6vw, 28px);
}

/* ============================================================
   Input panel
   ============================================================ */
.fields {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 7px;
}

.input-wrap {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-tint);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrap:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px var(--color-accent-soft);
}

.prefix {
    display: flex;
    align-items: center;
    padding: 0 0 0 14px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--color-muted);
}

.field input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 13px 14px;
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-ink);
    border-radius: var(--radius-md);
    min-width: 0;
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
}

.field input:focus {
    outline: none;
}

.period {
    display: flex;
    gap: 10px;
}

.period input {
    flex: 1;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface-tint);
    border-radius: var(--radius-md);
    padding: 13px 14px;
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-ink);
    min-width: 0;
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.period input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px var(--color-accent-soft);
}

.period select {
    flex: 0 0 auto;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface-tint);
    border-radius: var(--radius-md);
    padding: 0 32px 0 12px;
    font-family: var(--font-body);
    font-weight: 600;
    /* 16px is required, not just preferred: any font-size under 16px on a
       form control makes iOS Safari auto-zoom the page on focus. */
    font-size: 16px;
    color: var(--color-ink);
    cursor: pointer;
    min-height: 44px;
    /* Remove native OS chrome so the control looks the same in
       Chrome, Firefox, Safari and Edge, then draw a consistent custom arrow. */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235B6B63' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* Fallback: hide the leftover arrow in older IE/Edge Legacy if ever encountered */
.period select::-ms-expand {
    display: none;
}

.period select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px var(--color-accent-soft);
}

.field-error {
    margin: 6px 0 0;
    font-size: 12.5px;
    color: var(--color-negative);
    min-height: 15px;
}

/* Hide native number spinners for a cleaner, consistent look across browsers */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

.calc-btn {
    margin-top: 8px;
    padding: 15px;
    width: 100%;
    min-height: 44px;
    border: none;
    background: var(--color-accent);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15.5px;
    border-radius: var(--radius-md);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    transition: background var(--transition), transform var(--transition);
}

.calc-btn:hover {
    background: var(--color-primary-light);
}

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

.calc-btn:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* ============================================================
   Results panel
   ============================================================ */
.growth-strip {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.growth-row {
    display: grid;
    grid-template-columns: 62px 1fr auto;
    align-items: center;
    gap: 10px;
}

.growth-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 600;
}

.growth-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}

.growth-bar {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: width 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.growth-bar--invested {
    background: rgba(255, 255, 255, 0.55);
}

.growth-bar--returned {
    background: var(--color-accent);
}

.growth-value {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.result p {
    margin: 0 0 6px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 500;
}

.result--primary h2 {
    margin: 0;
    font-family: var(--font-mono);
    font-size: clamp(32px, 4.2vw, 42px);
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: color var(--transition);
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 16px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.result-grid h3 {
    margin: 0;
    font-family: var(--font-mono);
    font-size: clamp(19px, 2.2vw, 23px);
    font-weight: 600;
}

.result--negative h2,
.result--negative h3 {
    color: #F5A79B;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
    .calculator {
        grid-template-columns: 1fr;
        border-radius: var(--radius-md);
    }

    .result-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 768px) and (max-width: 1024px){
    .site-header-icon img {
   		width: 60px;
    	height: 60px;
	}
    
    .site-header-icon {
    	width: 60px;
    	height: 60px;
   	}
}

@media (max-width: 420px) {
    .site-header-inner {
        gap: 14px;
    }

    .site-header-icon {
        width: 60px;
        height: 60px;
    }

    .site-header-icon svg {
        width: 22px;
        height: 22px;
    }

    .growth-row {
        grid-template-columns: 52px 1fr;
        row-gap: 4px;
    }

    .growth-value {
        grid-column: 2;
        justify-self: end;
        font-size: 11.5px;
    }
    
    .site-header-icon img {
   		width: 60px;
    	height: 60px;
	}
}

/* High contrast focus ring for keyboard users, all interactive elements */
a:focus-visible,
input:focus-visible,
select:focus-visible,
button:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}