/* =============================================================
   MK Mortgage Calculator — calc.css
   All styles scoped to .mkc-wrap to avoid collisions.
   Customize with CSS variables or shortcode attributes.
   ============================================================= */

/* ── 1. CUSTOM PROPERTIES (Design Tokens) ─────────────────── */
.mkc-wrap {
    /* Colors — light theme */
    --mkc-bg:            #ffffff;
    --mkc-surface:       #f8f8f6;
    --mkc-border:        #e8e6e1;
    --mkc-text-primary:  #1a1a18;
    --mkc-text-secondary:#6b6860;
    --mkc-text-muted:    #a8a49e;
    --mkc-accent:        #1a3c5e;
    --mkc-accent-light:  rgba(26, 60, 94, 0.08);
    --mkc-interest-clr:  #c8863a;
    --mkc-shadow:        0 2px 20px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.04);

    /* Typography */
    --mkc-font:          'Georgia', 'Times New Roman', serif;
    --mkc-font-ui:       -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --mkc-radius:        14px;
    --mkc-radius-sm:     8px;
    --mkc-gap:           28px;
}

/* ── 2. DARK THEME ────────────────────────────────────────── */
.mkc-wrap.mkc-theme-dark {
    --mkc-bg:            #141414;
    --mkc-surface:       #1e1e1e;
    --mkc-border:        #2e2e2e;
    --mkc-text-primary:  #f0ede8;
    --mkc-text-secondary:#9a9690;
    --mkc-text-muted:    #5a5652;
    --mkc-accent:        #7eb3e0;
    --mkc-accent-light:  rgba(126, 179, 224, 0.1);
    --mkc-interest-clr:  #e8a058;
    --mkc-shadow:        0 2px 20px rgba(0,0,0,.4);
}

/* ── 3. OUTER SHELL ───────────────────────────────────────── */
.mkc-wrap {
    background:    var(--mkc-bg);
    border:        1px solid var(--mkc-border);
    border-radius: var(--mkc-radius);
    box-shadow:    var(--mkc-shadow);
    padding:       36px 40px;
    max-width:     860px;
    width:         100%;
    box-sizing:    border-box;
    font-family:   var(--mkc-font-ui);
    color:         var(--mkc-text-primary);
    /* Scope: reset only what matters */
    line-height:   1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ── 4. HEADER ────────────────────────────────────────────── */
.mkc-header {
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--mkc-border);
}

.mkc-title {
    font-family: var(--mkc-font);
    font-size:   1.5rem;
    font-weight: 400;
    letter-spacing: -.01em;
    color: var(--mkc-text-primary);
    line-height: 1.2;
    margin: 0 0 4px;
}

.mkc-subtitle {
    font-size: .85rem;
    color: var(--mkc-text-muted);
    font-family: var(--mkc-font-ui);
    margin: 0;
}

/* ── 5. TWO-COLUMN BODY ───────────────────────────────────── */
.mkc-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--mkc-gap);
    align-items: start;
}

@media (max-width: 640px) {
    .mkc-body { grid-template-columns: 1fr; }
    .mkc-wrap { padding: 24px 20px; }
}

/* ── 6. INPUT FIELDS ──────────────────────────────────────── */
.mkc-inputs {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.mkc-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mkc-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.mkc-label {
    font-size: .8rem;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--mkc-text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.mkc-input-wrap {
    display: flex;
    align-items: center;
    background: var(--mkc-surface);
    border: 1px solid var(--mkc-border);
    border-radius: var(--mkc-radius-sm);
    overflow: hidden;
    transition: border-color .15s;
}

.mkc-input-wrap:focus-within {
    border-color: var(--mkc-accent);
    outline: 2px solid var(--mkc-accent-light);
    outline-offset: 0;
}

.mkc-symbol {
    font-size: .9rem;
    color: var(--mkc-text-muted);
    padding: 0 10px;
    background: transparent;
    pointer-events: none;
    line-height: 1;
    flex-shrink: 0;
}

.mkc-input {
    border: none;
    background: transparent;
    font-family: var(--mkc-font-ui);
    font-size: .95rem;
    font-weight: 500;
    color: var(--mkc-text-primary);
    padding: 8px 10px 8px 0;
    width: 100%;
    min-width: 0;
    outline: none;
    -moz-appearance: textfield;
    text-align: right;
}

.mkc-input::-webkit-outer-spin-button,
.mkc-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.mkc-input-sm { width: 5ch; flex: 0 0 auto; }

/* ── 7. RANGE SLIDER ──────────────────────────────────────── */
.mkc-slider-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mkc-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--mkc-border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    position: relative;
}

/* Filled track via CSS custom property set by JS */
.mkc-slider {
    background: linear-gradient(
        to right,
        var(--mkc-accent) 0%,
        var(--mkc-accent) var(--mkc-fill, 0%),
        var(--mkc-border) var(--mkc-fill, 0%),
        var(--mkc-border) 100%
    );
}

.mkc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width:  16px;
    height: 16px;
    border-radius: 50%;
    background: var(--mkc-accent);
    border: 2px solid var(--mkc-bg);
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    cursor: pointer;
    transition: transform .1s;
}

.mkc-slider::-moz-range-thumb {
    width:  16px;
    height: 16px;
    border-radius: 50%;
    background: var(--mkc-accent);
    border: 2px solid var(--mkc-bg);
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    cursor: pointer;
    border: 2px solid var(--mkc-bg);
}

.mkc-slider:active::-webkit-slider-thumb { transform: scale(1.2); }
.mkc-slider:active::-moz-range-thumb     { transform: scale(1.2); }

.mkc-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: var(--mkc-text-muted);
}

/* ── 8. TERM TABS ─────────────────────────────────────────── */
.mkc-field-term { gap: 8px; }

.mkc-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.mkc-tab {
    background:    var(--mkc-surface);
    border:        1px solid var(--mkc-border);
    border-radius: var(--mkc-radius-sm);
    color:         var(--mkc-text-secondary);
    cursor:        pointer;
    font-family:   var(--mkc-font-ui);
    font-size:     .9rem;
    font-weight:   500;
    padding:       9px 4px;
    text-align:    center;
    transition:    background .15s, color .15s, border-color .15s;
    line-height:   1;
}

.mkc-tab-unit {
    font-size: .72rem;
    font-weight: 400;
    opacity: .7;
}

.mkc-tab:hover {
    background: var(--mkc-accent-light);
    border-color: var(--mkc-accent);
    color: var(--mkc-text-primary);
}

.mkc-tab--active {
    background:   var(--mkc-accent);
    border-color: var(--mkc-accent);
    color:        #fff;
}

.mkc-theme-dark .mkc-tab--active { color: var(--mkc-bg); }

/* ── 9. RESULTS PANEL ─────────────────────────────────────── */
.mkc-results {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

/* Monthly hero */
.mkc-monthly-wrap {
    text-align: center;
    background: var(--mkc-accent);
    border-radius: var(--mkc-radius);
    padding: 20px 24px 18px;
    width: 100%;
}

.mkc-monthly-label {
    display: block;
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255,255,255,.7);
    margin-bottom: 6px;
}

.mkc-monthly-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
}

.mkc-monthly-currency {
    font-family: var(--mkc-font);
    font-size: 1.4rem;
    font-weight: 400;
    color: rgba(255,255,255,.8);
    line-height: 1;
}

.mkc-monthly-amount {
    font-family: var(--mkc-font);
    font-size: 2.6rem;
    font-weight: 400;
    color: #fff;
    line-height: 1;
    letter-spacing: -.02em;
    transition: opacity .15s;
}

/* ── 10. DONUT CHART (CSS + SVG) ──────────────────────────── */
.mkc-chart-wrap {
    position: relative;
    width: 130px;
    height: 130px;
    flex-shrink: 0;
}

.mkc-donut {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.mkc-donut-track {
    fill: none;
    stroke: var(--mkc-border);
    stroke-width: 10;
}

.mkc-donut-principal {
    fill: none;
    stroke: var(--mkc-accent);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 289.03; /* 2π × r = 2π × 46 */
    stroke-dashoffset: 289.03;
    transition: stroke-dashoffset .5s cubic-bezier(.4,0,.2,1);
}

.mkc-donut-interest {
    fill: none;
    stroke: var(--mkc-interest-clr);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 289.03;
    stroke-dashoffset: 289.03;
    transition: stroke-dashoffset .5s cubic-bezier(.4,0,.2,1) .05s,
                stroke-rotate .5s;
}

.mkc-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.mkc-donut-pct {
    font-family: var(--mkc-font);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--mkc-text-primary);
    line-height: 1.1;
}

.mkc-donut-pct-label {
    font-size: .65rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--mkc-text-muted);
}

/* ── 11. LEGEND ───────────────────────────────────────────── */
.mkc-legend {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mkc-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mkc-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mkc-legend-dot--principal { background: var(--mkc-accent); }
.mkc-legend-dot--interest  { background: var(--mkc-interest-clr); }

.mkc-legend-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.mkc-legend-label {
    font-size: .8rem;
    color: var(--mkc-text-secondary);
}

.mkc-legend-value {
    font-size: .88rem;
    font-weight: 500;
    color: var(--mkc-text-primary);
    font-variant-numeric: tabular-nums;
    transition: opacity .15s;
}

/* ── 12. SUMMARY ROW ──────────────────────────────────────── */
.mkc-summary {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--mkc-surface);
    border: 1px solid var(--mkc-border);
    border-radius: var(--mkc-radius-sm);
    overflow: hidden;
}

.mkc-summary-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
}

.mkc-summary-divider {
    width: 1px;
    height: 40px;
    background: var(--mkc-border);
    flex-shrink: 0;
}

.mkc-summary-label {
    font-size: .7rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--mkc-text-muted);
}

.mkc-summary-value {
    font-size: .92rem;
    font-weight: 600;
    color: var(--mkc-text-primary);
    font-variant-numeric: tabular-nums;
    transition: opacity .15s;
}

/* ── 13. UPDATING STATE ───────────────────────────────────── */
.mkc-wrap.mkc-updating .mkc-monthly-amount,
.mkc-wrap.mkc-updating .mkc-legend-value,
.mkc-wrap.mkc-updating .mkc-summary-value {
    opacity: .4;
}

/* ── 14. ACCESSIBILITY ────────────────────────────────────── */
.mkc-tab:focus-visible,
.mkc-slider:focus-visible,
.mkc-input:focus-visible {
    outline: 2px solid var(--mkc-accent);
    outline-offset: 2px;
}
