/*
app/static/nuk_tools.css
=======================

Centralized stylesheet for NukTools.

Notes:
- This file is introduced incrementally to avoid regressions.
- Initial content: TER (Bubeck) page-specific rules (moved from ter_bubeck.html).
*/

:root {
    /* Generic (nt-*) tokens derived from TER_Bubeck */
    --nt-box-w: 12rem;
    --nt-label-w-left: 12.5rem;
    --nt-label-w-right: 14.5rem;
    --nt-label-w-io-right: 12.5rem;
    --nt-unit-w-right: 5rem;
    --nt-label-w-row: 18rem;
    --nt-gap-y: 0.55rem;
    --nt-gap-x: 0.6rem;
    --nt-mid-gap: 2.2rem;

    /* Charts */
    --nt-chart-svg-w: 92%;
    --nt-chart-top-margin: 0.9rem;

    /* Backward-compatible aliases (TB stays authoritative for now) */

    /* Brand palette */
    --bg: #4f4f4f;
    --nav: #000000;
    --card: #ffffff;
    --card-muted: #f5f5f5;

    --text: #d0d0d0;
    --text-dark: #111111;

    --primary: #2b60d8;
    --accent: #5b3aa6;
    --danger: #d40000;

    --border: rgba(255,255,255,0.20);
    --border-dark: rgba(0,0,0,0.35);

    /* Layout sizing */
    --container-max: 1200px;
    --gap: clamp(0.75rem, 2vw, 1.25rem);
    --pad: clamp(0.75rem, 2vw, 1.25rem);
    --radius: clamp(0.5rem, 1vw, 0.9rem);

    /* Typography scale */
    --fs-base: clamp(0.95rem, 1.2vw, 1.05rem);
    --fs-title: clamp(1.15rem, 2.2vw, 1.6rem);
        --fs-section: clamp(1.05rem, 1.35vw, 1.25rem);
--fs-subtitle: clamp(0.85rem, 1.1vw, 1rem);
    --fs-label: clamp(0.85rem, 1.1vw, 1.05rem);
    --fs-input: clamp(0.95rem, 1.4vw, 1.35rem);
    --fs-button: clamp(0.90rem, 1.1vw, 1.05rem);
    --fs-fineprint: clamp(0.82rem, 1.0vw, 0.95rem);

    --col-unit: clamp(3.5rem, 6vw, 5.5rem);
}



html, body { height: 100%; }

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: var(--fs-base);
}

header {
    background: var(--nav);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

nav a {
    color: #ffffff;
    text-decoration: none;
    padding: 0.45rem 0.6rem;
    border-radius: 0.45rem;
}

nav a.active {
    background: #ffd400;
    color: #000;
    font-weight: 700;
}

nav a:hover:not(.active) {
    text-decoration: underline;
}

.nt-page-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--pad);
    box-sizing: border-box;
}




    .nt-chart { width: 100%; display: flex; justify-content: center; margin-top: 0.9rem; }

    .nt-references {
        width: 100%;
        margin-top: 0.9rem;
        font-size: var(--fs-fineprint);
        line-height: 1.35;
        color: rgba(0,0,0,0.85);
        font-style: normal;
    }

    .nt-references .nt-ref-title {
        text-decoration: underline;
        margin-bottom: 0.35rem;
    }

/* =========================
   Generic components (nt-*)
   ========================= */

/* Mirrors TER_Bubeck layout but uses nt-* class names (no impact on TB pages). */

.nt-box { width: var(--nt-box-w); text-align: right; }

.nt-result {
    font-size: var(--fs-input);
    line-height: 1.15;
    padding: 0.42em 0.55em;
    box-sizing: border-box;
    border-radius: 0.5rem;
    background: #ffffff;
    border: 3px solid var(--accent);
    min-width: var(--nt-box-w);
    max-width: 100%;
    font-weight: 800;
    color: var(--text-dark);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.nt-form-row .nt-result {
    justify-self: end;
}

.nt-form-row {
    display: grid;
    grid-template-columns: var(--nt-label-w-row) var(--nt-box-w) auto;
    gap: var(--nt-gap-x);
    align-items: center;
}

.nt-meta-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.nt-meta-center .nt-form-row {
    width: max-content;
}

.nt-form-row .nt-label,
.nt-form-row .unit,
.nt-form-row .nt-unit { white-space: nowrap; margin: 0; }

.nt-form-grid {
    display: grid;
    grid-template-columns: var(--nt-label-w-left) var(--nt-box-w) auto;
    row-gap: var(--nt-gap-y);
    column-gap: var(--nt-gap-x);
    align-items: center;
}

.nt-form-grid .rlabel { text-align: right; white-space: nowrap; }
.nt-form-grid .runit { white-space: nowrap; }

.nt-form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: var(--nt-mid-gap);
    align-items: start;
}
.nt-sep { grid-column: 1 / -1; height: 0.8rem; }

.nt-centered-line {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    margin-top: 0.2rem;
}

.nt-info { font-size: var(--fs-label); color: rgba(0,0,0,0.85); white-space: nowrap; }

.nt-actions { display: flex; justify-content: flex-end; margin-top: var(--gap); }

/* =========================
   Charts (generic)
   ========================= */

.nt-chart { width: 100%; display: flex; justify-content: center; margin-top: var(--nt-chart-top-margin); }
.nt-chart svg { width: var(--nt-chart-svg-w); height: auto; display: block; }

/* =========================
   App-wide components (nt-*)
   ========================= */

/*
App-wide aliases that mirror the current base.html inline CSS.
This enables a safe, incremental migration:
- Existing pages keep their current classes.
- Pages can adopt nt-* classes (in addition to existing ones) with zero visual change.
- Once adoption is complete, base.html inline rules can be moved here and removed.
*/

.nt-card { background: var(--card); color: var(--text-dark); border: 1px solid var(--border-dark); border-radius: var(--radius); padding: var(--pad); box-sizing: border-box; }
.nt-card > h2 { margin: 2rem 0 0.35rem 0; font-size: var(--fs-title); }
.nt-card p { margin: 0.6rem 0; }
.nt-card > h2:first-child { margin-top: 0; }

.nt-legal-card { font-size: var(--fs-fineprint); line-height: 1.45; }
.nt-legal-card h2 { font-size: var(--fs-subtitle); margin-top: 2.2rem; margin-bottom: 0.25rem; }
.nt-legal-card p { margin: 0.45rem 0; }

.nt-tool-layout { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: var(--gap); align-items: stretch; min-height: clamp(420px, 70vh, 820px); }
@media (max-width: 900px) { .nt-tool-layout { grid-template-columns: 1fr; min-height: auto; } }

.nt-tool-image { width: 100%; height: auto; display: block; border: none; border-radius: 0; background: transparent; }

/* Preferences (logo) */
.nt-pref-panel { text-align: left; }
.nt-pref-logo {
    width: 260px;
    height: 260px;
    margin: 0.6rem auto 0;
    background: #ffffff;
    border: 2px solid var(--border-dark);
    border-radius: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.nt-pref-logo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}
.nt-hidden { display: none; }

.nt-panel { background: var(--card-muted); border: 2px solid var(--primary); border-radius: var(--radius); padding: var(--pad); box-sizing: border-box; }

input.nt-input-number,
select.nt-input-number {
    font-family: inherit;
    font-size: var(--fs-input);
    line-height: 1.15;
    padding: 0.42em 0.55em;
    width: 100%;
    box-sizing: border-box;
    border-radius: 0.5rem;
    background: #fffbd6;
    border: 3px solid var(--primary);
    outline: none;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
}

input.nt-input-number,
select.nt-input-number { text-align: right; }

.nt-unit { font-size: var(--fs-label); font-style: italic; opacity: 0.85; }


.nt-btn-primary {
    font-size: var(--fs-button);
    padding: 0.75em 1.1em;
    border-radius: 0.6rem;
    border: 2px solid var(--primary);
    background: #ffffff;
    color: #000000;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 0.15rem 0.35rem rgba(0,0,0,0.2);
}

.nt-btn-primary:active { transform: translateY(1px); }

.nt-status-line { margin-top: 0.6rem; min-height: 1.2rem; font-size: 0.95rem; color: #333; }

/* =========================
   Utilities (no page-specific)
   ========================= */

.nt-text-center { text-align: center; }

.nt-m0 { margin: 0; }
.nt-mb0 { margin-bottom: 0; }
.nt-mt-gap { margin-top: var(--gap); }
.nt-mb-gap { margin-bottom: var(--gap); }

.nt-mt-xs { margin-top: 0.45rem; }
.nt-mt-sm { margin-top: 0.5rem; }

.nt-spacer { height: var(--gap); }
.nt-lh-14 { line-height: 1.4; }


.nt-img-block-center { display: block; margin-left: auto; margin-right: auto; height: auto; }
.nt-img-hero { max-width: min(900px, 100%); }

.nt-text-left { text-align: left; }

.nt-text-right { text-align: right; }

.nt-grid-unit { display: grid; grid-template-columns: 1fr var(--col-unit); gap: 0.6rem; align-items: center; }



.nt-table { width: 100%; border-collapse: collapse; color: var(--text-dark); }

.nt-tr-muted { background: var(--card-muted); }

.nt-th { text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--border-dark); font-size: var(--fs-subtitle); }

.nt-td-compact { padding: 0.45rem 0.8rem; border-bottom: 1px solid rgba(0,0,0,0.08); }

/* Step 5C: generic utilities (no page-specific) */
.nt-inline-block { display: inline-block; }
.nt-border-dark { border-color: var(--border-dark); }
.nt-hr { margin: 1.0rem 0; border: none; border-top: 1px solid rgba(0,0,0,0.12); }
.nt-gridcols-1fr { grid-template-columns: 1fr; }

/* =========================
   Typography (canonical, no page-specific)
   ========================= */

/* Page titles */
.nt-h1,

/* Section titles (TER_Bubeck reference) */
.nt-h2 { margin: 0 0 0.6rem 0; font-size: var(--fs-title); }
.nt-h3 { margin: 0 0 0.6rem 0; font-size: var(--fs-section); }

/* Guardrails: ensure section headers keep the intended hierarchy */
.nt-panel h3.nt-h3,
.nt-card h3.nt-h3{
    font-size: var(--fs-section);
}

/* Backward-compatible alias used during migration */
/* Body text */
.nt-text { margin: 0.6rem 0; }
.nt-text-compact { margin: 0.35rem 0; line-height: 1.45; }
.nt-card:not(.nt-text-center) p,
.nt-text,
.nt-text-compact {
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
}

/* Small / fine print */
.nt-small { font-size: var(--fs-fineprint); line-height: 1.35; }
.nt-muted { opacity: 0.85; }

/* Legend-like annotations */
/* Emphasis */
.nt-strong { font-weight: 800; }

/* Form labels (canonical): right-aligned, "Excel-like" */
.nt-label {
    font-size: var(--fs-label);
    font-weight: 600;
    text-align: right;
    justify-self: end;
}

/* Results (typography only; box styling is defined in the component section) */
.nt-results-wrap { display: flex; justify-content: center; width: 100%; }
.nt-results-box { display: inline-block; }
.nt-result-row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.nt-result-row--grid { display: grid; grid-template-columns: 1fr auto auto; column-gap: 0.7rem; align-items: baseline; }
.nt-result-label { font-size: var(--fs-label); font-weight: 600; text-align: right; }
.nt-result-value,
.nt-results-value { display: inline-flex; align-items: baseline; gap: 0.35rem; white-space: nowrap; }
.nt-result-meta { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--fs-fineprint); color: rgba(0,0,0,0.6); white-space: nowrap; }
.nt-result-list { display: grid; row-gap: 0.25rem; margin-top: 0.35rem; }
.nt-result-val { text-align: right; font-weight: 700; min-width: 6ch; }

/* Input state helpers */
input.is-invalid,
select.is-invalid,
textarea.is-invalid,
.nt-result.is-invalid,
.nt-box.is-invalid {
    border-color: var(--danger) !important;
}
/* Form tools (generic) */
.nt-form-tools {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.35rem;
}


.nt-form-reset {
    font-size: var(--fs-small);
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

.nt-form-reset:hover {
    color: rgba(0, 0, 0, 0.85);
}
/* Plot sizing: keep SVG responsive and avoid layout shifts */
.nt-chart svg{
    display:block;
    width:100%;
    height:auto;
}

/* --- Tool layout helpers --- */
.nt-tool-figure {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.nt-planner-hero-img {
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    display: block;
    margin: 0;
}

.nt-planner-single .nt-panel,
.nt-planner-single .nt-planner-hero {
    width: 100%;
    max-width: none;
    margin-left: auto;
    margin-right: auto;
}

.nt-planner-hero {
    display: flex;
    justify-content: center;
}

/* Section spacer used between major panels (e.g., Schedule -> Results) */
.nt-section-spacer {
    height: var(--gap);
}

/* Scrollable table container (Planner schedule reference) */
.nt-table-wrap {
    max-height: 22rem;
    overflow: auto;
    margin-top: 0.55rem;
    border-radius: var(--radius);
}


.nt-table-wrap--narrow {
    width: 60%;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 900px) {
    .nt-table-wrap--narrow { width: 100%; }
}

@media (max-width: 700px) {
    .nt-tool-figure {
        max-width: 100%;
        overflow: hidden;
    }

    .nt-tool-image-tall {
        max-width: 100%;
        height: auto;
        max-height: 50vh;
        object-fit: contain;
        display: block;
    }

    .nt-form-row {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "label label"
            "input unit";
    }

    .nt-form-row .nt-label { grid-area: label; }
    .nt-form-row .nt-box { grid-area: input; }
    .nt-form-row .nt-unit {
        grid-area: unit;
        align-self: center;
    }

    .nt-meta-center .nt-form-row {
        width: 100%;
    }

    .nt-box {
        width: 100%;
    }

    .nt-label,
    .nt-unit {
        text-align: left;
        justify-self: start;
        white-space: normal;
    }

    .nt-form-grid {
        grid-template-columns: 1fr auto;
        column-gap: 0.6rem;
    }

    .nt-form-grid-2col {
        grid-template-columns: 1fr;
        row-gap: var(--nt-gap-y);
    }

    .nt-form-grid .nt-label {
        grid-column: 1 / -1;
    }

    .nt-form-grid .nt-input-number,
    .nt-form-grid .nt-result {
        grid-column: 1;
    }

    .nt-form-grid .nt-unit {
        grid-column: 2;
        align-self: center;
    }

    .nt-form-grid > div:empty {
        display: none;
    }

    .nt-form-grid .rlabel {
        text-align: left;
        justify-items: start;
    }



    .nt-result-row {
        justify-content: flex-start;
    }

    .nt-result-meta {
        white-space: normal;
        flex-wrap: wrap;
    }

    .nt-result-row--grid {
        grid-template-columns: 1fr auto;
        row-gap: 0.15rem;
    }

    .nt-result-row--grid .nt-result-label {
        grid-column: 1 / -1;
        text-align: left;
    }

    .nt-result-row--grid .nt-result-val,
    .nt-result-row--grid .nt-unit {
        text-align: left;
        white-space: normal;
    }

    .nt-panel-split {
        gap: calc(var(--gap) * 0.75);
    }

    .nt-table-wrap {
        width: 100%;
        overflow-x: auto;
    }

    .nt-card:not(.nt-text-center) p,
    .nt-text,
    .nt-text-compact {
        text-align: justify;
        text-justify: inter-word;
        hyphens: auto;
    }
}

/* Panel footer actions (e.g., report button) */
.nt-panel-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--gap);
}
