/* ============================================================
   UtilityHub — visual identity
   Concept: "console-grade utilities". The tools are precise,
   deterministic input->output machines, so the design borrows
   the vocabulary of a terminal (the >_ mark, mono labels,
   monospace data) but sits it on warm paper rather than the
   clichéd black-terminal look. One accent: indigo.
   ============================================================ */

:root {
    --paper: #F7F4EF;
    --paper-2: #FFFFFF;
    --ink: #1C1A2E;
    --ink-soft: #55516B;
    --ink-faint: #8B8798;
    --accent: #3A34D2;
    --accent-ink: #2A24B0;
    --line: #E4DED4;
    --line-2: #D8D1C4;
    --danger: #B4322A;
    --ok: #2F7D4F;
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --wrap: 1080px;
    --radius: 10px;
    --radius-sm: 6px;
}

* {
    box-sizing: border-box;
}

/* The [hidden] attribute must always win, even over elements that set their own
   display (e.g. .tool-card is display:flex). Without this, JS toggling
   element.hidden silently fails to hide fl/grid/inline-flex elements — which
   otherwise breaks the tool search, the category filters and the file lists. */
[hidden] {
    display: none !important;
}

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: 24px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

    a:hover {
        color: var(--accent-ink);
        text-decoration: underline;
    }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--ink);
    color: var(--paper);
    padding: 10px 16px;
    z-index: 100;
}

    .skip-link:focus {
        left: 8px;
        top: 8px;
    }

/* ---------- Header ---------- */
.site-header {
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(8px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.brand {
    display: inline-flex;
    align-items: baseline;
    gap: 9px;
    color: var(--ink);
    font-weight: 600;
}

    .brand:hover {
        text-decoration: none;
        color: var(--ink);
    }

.brand-mark {
    font-family: var(--font-mono);
    color: var(--accent);
    font-weight: 500;
    letter-spacing: -0.05em;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 1.22rem;
    letter-spacing: -0.01em;
}

.site-nav {
    display: flex;
    gap: 26px;
}

    .site-nav a {
        color: var(--ink-soft);
        font-size: 0.95rem;
        font-weight: 500;
    }

        .site-nav a:hover {
            color: var(--accent);
            text-decoration: none;
        }

/* ---------- Hero ---------- */
.hero {
    padding-top: 72px;
    padding-bottom: 40px;
    text-align: left;
}

.hero-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 20px;
}

    .hero-eyebrow::before {
        content: "> ";
    }

.hero-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.3rem, 5.4vw, 3.8rem);
    line-height: 1.04;
    letter-spacing: -0.02em;
    margin: 0 0 20px;
    color: var(--ink);
}

.hero-lede {
    max-width: 46ch;
    color: var(--ink-soft);
    font-size: 1.12rem;
    margin: 0 0 36px;
}

/* ---------- Search ---------- */
.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--paper-2);
    border: 1.5px solid var(--line-2);
    border-radius: var(--radius);
    padding: 4px 18px;
    max-width: 560px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .search-box:focus-within {
        border-color: var(--accent);
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
    }

.search-prompt {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 1.1rem;
}

#toolSearch {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 1.02rem;
    color: var(--ink);
    padding: 12px 0;
}

    #toolSearch::placeholder {
        color: var(--ink-faint);
    }

/* ---------- Filter chips ---------- */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 20px;
}

.chip {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid var(--line-2);
    border-radius: 100px;
    padding: 7px 15px;
    cursor: pointer;
    transition: all 0.14s ease;
}

    .chip:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

.chip--active {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

    .chip--active:hover {
        color: var(--paper);
    }

/* ---------- Tool grid ---------- */
.tool-grid-section {
    padding-top: 34px;
    padding-bottom: 80px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
    gap: 16px;
}

.tool-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 22px 24px;
    color: var(--ink);
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
    position: relative;
    overflow: hidden;
}

    .tool-card::before {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 3px;
        background: var(--accent);
        transform: scaleY(0);
        transform-origin: top;
        transition: transform 0.18s ease;
    }

    .tool-card:hover {
        text-decoration: none;
        color: var(--ink);
        transform: translateY(-3px);
        border-color: var(--line-2);
        box-shadow: 0 10px 28px -14px rgba(28, 26, 46, 0.28);
    }

        .tool-card:hover::before {
            transform: scaleY(1);
        }

.tool-card-cat {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
}

.tool-card-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.24rem;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.tool-card-summary {
    color: var(--ink-soft);
    font-size: 0.94rem;
    line-height: 1.5;
}

.no-results {
    text-align: center;
    color: var(--ink-faint);
    font-family: var(--font-mono);
    padding: 40px 0;
}

/* ---------- Tool page ---------- */
.tool-page {
    padding-top: 40px;
    padding-bottom: 80px;
    max-width: 820px;
}

.crumb {
    display: flex;
    gap: 10px;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--ink-faint);
    margin-bottom: 26px;
}

    .crumb a {
        color: var(--ink-soft);
    }

.tool-head {
    margin-bottom: 34px;
}

.tool-head-cat {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

.tool-head h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 4.4vw, 2.7rem);
    letter-spacing: -0.02em;
    line-height: 1.08;
    margin: 10px 0 12px;
}

.tool-head-summary {
    color: var(--ink-soft);
    font-size: 1.12rem;
    margin: 0;
    max-width: 54ch;
}

/* ---------- Workbench (the interactive area) ---------- */
.tool-workbench {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
}

.field {
    margin-bottom: 18px;
}

    .field:last-child {
        margin-bottom: 0;
    }

    .field label {
        display: block;
        font-family: var(--font-mono);
        font-size: 0.8rem;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--ink-soft);
        margin-bottom: 9px;
    }

textarea, input[type="file"], input[type="number"], input[type="date"], input[type="text"], select {
    width: 100%;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--ink);
    background: var(--paper);
    border: 1.5px solid var(--line-2);
    border-radius: var(--radius-sm);
    padding: 14px;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    input[type="number"], input[type="date"], input[type="text"], select {
        resize: none;
    }

    textarea.mono, .output.mono {
        font-family: var(--font-mono);
        font-size: 0.92rem;
        line-height: 1.55;
    }

    textarea:focus, input[type="file"]:focus, input[type="number"]:focus, input[type="date"]:focus, input[type="text"]:focus, select:focus {
        outline: none;
        border-color: var(--accent);
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
    }

.field-hint {
    font-size: 0.86rem;
    color: var(--ink-faint);
    margin: 8px 0 0;
}

.btn {
    display: inline-block;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.98rem;
    color: var(--paper-2);
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    padding: 13px 26px;
    cursor: pointer;
    transition: background 0.14s ease, transform 0.1s ease;
}

    .btn:hover {
        background: var(--accent-ink);
        text-decoration: none;
        color: var(--paper-2);
    }

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

    .btn:disabled {
        opacity: 0.6;
        cursor: default;
        transform: none;
    }

.btn-secondary {
    color: var(--accent);
    background: transparent;
    border: 1.5px solid var(--line-2);
}

    .btn-secondary:hover {
        color: var(--accent);
        background: color-mix(in srgb, var(--accent) 8%, var(--paper));
        border-color: var(--accent);
    }

/* GPA: repeatable course rows */
.gpa-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.gpa-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--ink-faint);
    background: var(--paper);
    border: 1.5px solid var(--line-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.14s ease, border-color 0.14s ease;
}

    .gpa-remove:hover {
        color: var(--danger);
        border-color: var(--danger);
    }

    .gpa-remove:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

.result-field {
    margin-top: 22px;
}

.output {
    background: var(--paper);
    border: 1.5px solid var(--line-2);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ink);
    max-height: 460px;
    overflow: auto;
}

.output--error {
    border-color: var(--danger);
    color: var(--danger);
}

/* Output header: label on the left, copy control on the right */
.field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 9px;
}

    .field-head label {
        margin-bottom: 0;
    }

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft);
    background: var(--paper);
    border: 1.3px solid var(--line-2);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    cursor: pointer;
    transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

    .copy-btn:hover {
        color: var(--accent);
        border-color: var(--accent);
    }

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

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

    .copy-btn.copied {
        color: var(--accent);
        border-color: var(--accent);
        background: color-mix(in srgb, var(--accent) 8%, var(--paper));
    }

    .copy-btn .copy-ico {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

/* Segmented encode/decode (or similar) toggle */
.seg {
    display: inline-flex;
    border: 1.5px solid var(--line-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 18px;
}

    .seg label {
        display: inline-flex;
        align-items: center;
        font-family: var(--font-mono);
        font-size: 0.78rem;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--ink-soft);
        padding: 9px 18px;
        cursor: pointer;
        transition: background 0.14s ease, color 0.14s ease;
    }

        .seg label:not(:last-child) {
            border-right: 1.5px solid var(--line-2);
        }

        .seg label:hover {
            color: var(--accent);
        }

        /* Visually hide the radio itself; the label carries the UI. */
        .seg label input {
            position: absolute;
            opacity: 0;
            width: 0;
            height: 0;
        }

        .seg label:has(input:checked) {
            background: var(--accent);
            color: var(--paper-2);
        }

        .seg label:has(input:focus-visible) {
            outline: 2px solid var(--accent);
            outline-offset: 2px;
        }

.alert {
    background: color-mix(in srgb, var(--danger) 8%, var(--paper-2));
    border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
    color: var(--danger);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 22px;
}

/* Word counter live stats */
.wc-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-top: 20px;
}

.stat {
    text-align: center;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 18px 10px;
}

.stat-num {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.9rem;
    color: var(--accent);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-top: 8px;
    display: block;
}

/* ---------- Calculators ---------- */
.calc-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

/* Highlighted answer panel shared by the calculators */
.calc-result {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 20px 22px;
}

.calc-result-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.calc-number {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2.4rem;
    color: var(--accent);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.calc-unit {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.calc-note {
    margin: 10px 0 0;
    font-size: 1rem;
    color: var(--ink-soft);
}

/* Age: a small row of year/month/day figures */
.calc-figures {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
}

.calc-figure .calc-number {
    font-size: 2rem;
}

.calc-figure-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-top: 6px;
}

/* Percentage: three inline expressions */
.calc-group {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    margin-bottom: 16px;
}

    .calc-group legend {
        font-family: var(--font-mono);
        font-size: 0.74rem;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--ink-soft);
        padding: 0 8px;
    }

.calc-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 1.02rem;
    color: var(--ink);
}

    .calc-inline input[type="number"] {
        width: 96px;
        padding: 9px 11px;
    }

.calc-inline-result {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    min-width: 2ch;
}

/* ---------- Tool written content (About / FAQ) ---------- */
.tool-content {
    margin-top: 44px;
}

.content-block {
    margin-bottom: 40px;
}

    .content-block h2 {
        font-family: var(--font-display);
        font-weight: 600;
        font-size: 1.5rem;
        letter-spacing: -0.01em;
        margin: 0 0 14px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--line);
    }

    .content-block p {
        color: var(--ink-soft);
        margin: 0 0 14px;
    }

.faq {
    margin: 0;
}

.faq-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

    .faq-item:last-child {
        border-bottom: none;
    }

    .faq-item dt {
        font-weight: 600;
        color: var(--ink);
        margin-bottom: 6px;
    }

    .faq-item dd {
        margin: 0;
        color: var(--ink-soft);
    }

/* Merge PDF selected-file list */
.file-list {
    list-style: none;
    margin: 4px 0 22px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--paper);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.file-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.file-name {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 0.78rem;
    color: var(--ink-faint);
}

.file-remove {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-family: var(--font-mono);
    font-size: 1.15rem;
    line-height: 1;
    color: var(--danger);
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease;
}

    .file-remove:hover {
        background: var(--danger);
        color: var(--paper-2);
    }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- Ad slot ---------- */
.ad-slot {
    margin: 8px 0 4px;
    min-height: 90px;
}

.ad-slot--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--line-2);
    border-radius: var(--radius-sm);
    color: var(--ink-faint);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: color-mix(in srgb, var(--paper) 60%, transparent);
}

/* ---------- Prose pages (privacy, error) ---------- */
.prose-page {
    padding-top: 48px;
    padding-bottom: 80px;
    max-width: 680px;
}

    .prose-page h1 {
        font-family: var(--font-display);
        font-weight: 600;
        font-size: clamp(2rem, 4.4vw, 2.7rem);
        letter-spacing: -0.02em;
        margin: 0 0 16px;
    }

.prose-lede {
    font-size: 1.15rem;
    color: var(--ink-soft);
    margin-bottom: 34px;
}

/* Status / error pages: big faint code above the heading */
.status-code {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: clamp(3.5rem, 12vw, 6rem);
    line-height: 1;
    color: var(--line-2);
    margin: 0 0 8px;
}

.prose-page h2 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.4rem;
    margin: 32px 0 12px;
}

.prose-page p {
    color: var(--ink-soft);
}

/* ---------- Home intro content ---------- */
.home-about {
    max-width: 720px;
    padding-top: 8px;
    padding-bottom: 72px;
}

    .home-about h2 {
        font-family: var(--font-display);
        font-weight: 600;
        font-size: clamp(1.4rem, 3vw, 1.8rem);
        letter-spacing: -0.01em;
        margin: 0 0 16px;
    }

    .home-about p {
        color: var(--ink-soft);
        line-height: 1.7;
        margin: 0 0 16px;
    }

        .home-about p:last-child {
            margin-bottom: 0;
        }

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--line);
    background: var(--paper-2);
    margin-top: auto;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 28px;
    padding-top: 30px;
    padding-bottom: 30px;
}

.footer-brand {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 600;
}

.footer-meta {
    color: var(--ink-faint);
    font-size: 0.9rem;
}

.footer-nav {
    margin-left: auto;
    display: flex;
    gap: 20px;
}

    .footer-nav a {
        color: var(--ink-soft);
        font-size: 0.9rem;
    }

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
    body {
        font-size: 16px;
    }

    .wc-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .tool-workbench {
        padding: 20px;
    }

    .footer-nav {
        margin-left: 0;
        width: 100%;
    }
}

/* ---------- Accessibility niceties ---------- */
:focus-visible {
    outline: 2.5px solid var(--accent);
    outline-offset: 2px;
}

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