/**
 * Factor Calculator Styles
 * 약수·소인수분해 계산기 전용 스타일
 *
 * @package Zipper
 */

.facc-hidden {
    display: none !important;
}

#faccCalculator {
    --bg: #faf9f7;
    --surface: #ffffff;
    --border: #e8e4dc;
    --text: #2d2a26;
    --muted: #5f5a56;
    --accent: #b8860b;
    --accent-light: #fbf7eb;
    --accent-mid: #eadfb8;
    --success: #8a6500;
    --success-light: #fdf8e8;
    --mono: 'Courier New', Courier, monospace;
    --sans: Helvetica, Arial, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);
    color: var(--text);
    font-family: var(--sans);
}

#faccCalculator * {
    box-sizing: border-box;
}

#faccCalculator .facc-shell {
    display: grid;
    gap: 8px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg);
    box-shadow: var(--shadow);
}

.facc-tool-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.facc-heading-block {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.facc-tool-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--text);
    font-size: clamp(19px, 2.1vw, 24px);
    line-height: 1.2;
    letter-spacing: -0.03em;
}

.facc-tool-heading i,
.facc-header-badges i,
.facc-panel-head i,
.facc-disclaimer i,
.facc-action-btn i {
    color: var(--accent);
}

.facc-lead {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.38;
}

.facc-header-badges {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    flex: 0 0 auto;
}

.facc-header-badges span,
.facc-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    padding: 4px 8px;
    border: 1px solid var(--accent-mid);
    border-radius: 999px;
    background: var(--accent-light);
    color: var(--success);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.facc-input-strip {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(230px, 0.68fr) auto;
    align-items: end;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.facc-input-main,
.facc-preset-block,
.facc-action-block {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.facc-panel-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.facc-input-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 32px auto;
    align-items: center;
    gap: 6px;
}

.facc-amount-input {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.facc-amount-input:hover {
    border-color: var(--accent-mid);
}

.facc-amount-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.12);
}

.facc-amount-input::placeholder {
    color: #bdb8ae;
    font-weight: 700;
}

.facc-clear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--muted);
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.facc-clear-btn:hover {
    border-color: var(--accent-mid);
    background: var(--accent-light);
    color: var(--accent);
}

.facc-unit-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-height: 32px;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.facc-input-status {
    min-height: 15px;
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.facc-input-status.is-error {
    color: #a64040;
    font-weight: 700;
}

.facc-input-status.is-ok {
    color: var(--success);
    font-weight: 700;
}

.facc-preset-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
}

.facc-preset-btn {
    min-height: 32px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.facc-preset-btn:hover,
.facc-preset-btn.is-active {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.facc-action-block {
    grid-template-columns: 1fr;
    min-width: 126px;
}

.facc-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--accent-mid);
    border-radius: 9px;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.facc-action-btn:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    box-shadow: 0 4px 10px rgba(184, 134, 11, 0.12);
}

.facc-reset-btn {
    background: #fff;
    color: var(--muted);
}

.facc-waiting {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #f1d6bf;
    border-radius: var(--radius);
    background: #fff8f1;
    color: #9e5f35;
    font-size: 13px;
    font-weight: 700;
}

.facc-waiting i {
    color: #c47b2c;
    font-size: 18px;
}

.facc-waiting p {
    margin: 0;
    line-height: 1.4;
}

.facc-dashboard {
    display: grid;
    grid-template-columns: minmax(270px, 1.05fr) minmax(240px, 0.78fr) minmax(250px, 0.92fr);
    grid-template-areas:
        "hero kpis factors"
        "prime prime pairs";
    gap: 8px;
    align-items: stretch;
}

.facc-result-hero,
.facc-kpi-grid,
.facc-panel,
.facc-disclaimer {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.facc-result-hero {
    grid-area: hero;
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
    padding: 12px;
    border-color: var(--accent-mid);
    background: linear-gradient(135deg, #fffaf0 0%, #f6edcf 100%);
}

.facc-result-hero.is-prime {
    border-color: #cfe4d4;
    background: linear-gradient(135deg, #fbfff8 0%, #edf8ee 100%);
}

.facc-result-hero.is-unit {
    border-color: #d8dced;
    background: linear-gradient(135deg, #fbfbff 0%, #eef1fb 100%);
}

.facc-hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.facc-status-badge,
.facc-hero-caption,
.facc-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 22px;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 800;
    white-space: nowrap;
}

.facc-status-badge {
    background: rgba(184, 134, 11, 0.13);
    color: var(--accent);
}

.facc-status-badge.is-example,
.facc-status-badge.is-composite {
    background: rgba(184, 134, 11, 0.13);
    color: var(--accent);
}

.facc-status-badge.is-prime {
    background: rgba(77, 148, 92, 0.14);
    color: #2d7a4e;
}

.facc-status-badge.is-unit {
    background: rgba(93, 112, 175, 0.14);
    color: #4054a8;
}

.facc-status-badge.is-warning {
    background: rgba(220, 80, 80, 0.12);
    color: #a64040;
}

.facc-hero-caption {
    border: 1px solid rgba(184, 134, 11, 0.18);
    background: rgba(255, 255, 255, 0.55);
    color: var(--muted);
}

.facc-hero-value {
    color: var(--text);
    font-family: var(--mono);
    font-size: clamp(32px, 4.2vw, 46px);
    font-weight: 900;
    line-height: 0.98;
    letter-spacing: -0.06em;
}

.facc-hero-value .unit {
    margin-left: 4px;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.facc-hero-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.facc-formula-box {
    min-width: 0;
    padding: 7px 9px;
    border: 1px solid rgba(184, 134, 11, 0.18);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.74);
    color: var(--text);
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.28;
    overflow-wrap: anywhere;
}

.facc-hero-summary {
    margin: 0;
    color: #4d4742;
    font-size: 12px;
    line-height: 1.35;
}

.facc-meta-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.facc-meta-pill {
    border: 1px solid rgba(184, 134, 11, 0.16);
    background: rgba(255, 255, 255, 0.64);
    color: var(--muted);
}

.facc-kpi-grid {
    grid-area: kpis;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    overflow: hidden;
}

.facc-kpi-card {
    display: grid;
    align-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 68px;
    padding: 9px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.facc-kpi-card:nth-child(2n) {
    border-right: 0;
}

.facc-kpi-card:nth-child(n+3) {
    border-bottom: 0;
}

.facc-kpi-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.25;
}

.facc-kpi-value {
    color: var(--text);
    font-family: var(--mono);
    font-size: clamp(18px, 1.8vw, 23px);
    font-weight: 900;
    line-height: 1.08;
    letter-spacing: -0.04em;
    overflow-wrap: anywhere;
}

.facc-panel {
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
    padding: 10px;
}

.facc-prime-panel {
    grid-area: prime;
}

.facc-factor-panel {
    grid-area: factors;
}

.facc-pair-panel {
    grid-area: pairs;
}

.facc-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.facc-panel-head h3 {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.2;
}

.facc-panel-head span {
    min-width: 0;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.3;
    text-align: right;
}

.facc-prime-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
    gap: 6px;
}

.facc-prime-card,
.facc-prime-empty {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 7px;
    border: 1px solid #ece7dc;
    border-radius: 9px;
    background: var(--bg);
}

.facc-prime-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
}

.facc-prime-power {
    color: var(--text);
    font-family: var(--mono);
    font-size: 17px;
    font-weight: 900;
    line-height: 1.1;
}

.facc-prime-chip {
    display: inline-flex;
    align-items: center;
    gap: 0;
    min-height: 20px;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 10.5px;
    font-weight: 800;
    white-space: nowrap;
}

.facc-prime-bar-track {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #ece7dc;
}

.facc-prime-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #d4af37 0%, #b8860b 100%);
}

.facc-prime-meta,
.facc-prime-empty {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.25;
}

.facc-factor-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 136px;
    min-height: 88px;
    overflow-y: auto;
    padding: 1px 4px 1px 1px;
}

.facc-factor-chip,
.facc-factor-chip.is-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-height: 24px;
    padding: 4px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.facc-factor-chip.is-placeholder {
    background: var(--bg);
    color: var(--muted);
    font-family: var(--sans);
}

.facc-table-wrap {
    max-height: 144px;
    max-width: 100%;
    min-width: 0;
    overflow: auto;
    border: 1px solid #ece7dc;
    border-radius: 9px;
}

.facc-pair-table {
    width: 100%;
    min-width: 300px;
    border-collapse: collapse;
    background: #fff;
}

.facc-pair-table th,
.facc-pair-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #ece7dc;
    color: var(--text);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.25;
    text-align: left;
    white-space: nowrap;
}

.facc-pair-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg);
    color: var(--muted);
    font-family: var(--sans);
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.facc-pair-table td:last-child,
.facc-pair-table th:last-child {
    text-align: right;
}

.facc-pair-table tr:last-child td {
    border-bottom: 0;
}

.facc-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

@media (max-width: 1080px) {
    .facc-input-strip {
        grid-template-columns: minmax(280px, 1fr) minmax(220px, 0.8fr);
    }

    .facc-action-block {
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .facc-dashboard {
        grid-template-columns: minmax(280px, 1fr) minmax(260px, 0.9fr);
        grid-template-areas:
            "hero kpis"
            "prime factors"
            "pairs pairs";
    }
}

@media (max-width: 820px) {
    #faccCalculator .facc-shell {
        padding: 10px;
    }

    .facc-tool-header,
    .facc-input-strip,
    .facc-dashboard {
        grid-template-columns: 1fr;
    }

    .facc-tool-header {
        display: grid;
        gap: 8px;
    }

    .facc-header-badges {
        justify-content: flex-start;
    }

    .facc-input-strip {
        align-items: stretch;
    }

    .facc-action-block {
        grid-column: auto;
    }

    .facc-dashboard {
        grid-template-areas:
            "hero"
            "kpis"
            "prime"
            "factors"
            "pairs";
    }

    .facc-factor-chip-list,
    .facc-table-wrap {
        max-height: 170px;
    }
}

@media (max-width: 520px) {
    #faccCalculator .facc-shell {
        padding: 10px;
        border-radius: 14px;
    }

    .facc-input-wrap {
        grid-template-columns: minmax(0, 1fr) 32px;
    }

    .facc-unit-chip {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .facc-preset-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .facc-action-block,
    .facc-kpi-grid {
        grid-template-columns: 1fr;
    }

    .facc-kpi-card,
    .facc-kpi-card:nth-child(2n),
    .facc-kpi-card:nth-child(n+3) {
        min-height: 72px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .facc-kpi-card:last-child {
        border-bottom: 0;
    }

    .facc-panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .facc-panel-head span {
        text-align: left;
    }

    .facc-pair-table {
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .facc-amount-input,
    .facc-clear-btn,
    .facc-preset-btn,
    .facc-action-btn {
        transition: none !important;
    }

    .facc-action-btn:hover {
        transform: none !important;
    }
}
