/* ==========================================================================
   WebTools design system: tokens, base elements, layout and shared controls.
   Page-specific styles live next to their components (*.razor.css).
   ========================================================================== */

:root {
    color-scheme: light dark;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-muted: #f0f2f7;
    --surface-raised: #ffffff;
    --border: #e2e5ee;
    --border-strong: #cdd2de;
    --text: #151a27;
    --text-muted: #555e73;
    --text-subtle: #7d859a;

    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef0ff;
    --accent-text: #ffffff;
    --accent-gradient: linear-gradient(135deg, #6366f1, #7c3aed);

    --success: #15803d;
    --danger: #c42b2b;
    --danger-soft: #fdf1f1;
    --warning: #8a4b06;
    --warning-soft: #fff8e6;
    --warning-border: #f6dc9c;

    --checker: #e4e7ee;
    --focus-ring: 0 0 0 3px rgb(79 70 229 / 0.25);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.05);
    --shadow: 0 1px 2px rgb(16 24 40 / 0.05), 0 12px 32px -16px rgb(16 24 40 / 0.22);

    --header-height: 64px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1017;
        --surface: #151a24;
        --surface-muted: #1b212d;
        --surface-raised: #2a3244;
        --border: #262e3e;
        --border-strong: #384154;
        --text: #e8ebf2;
        --text-muted: #a5adc0;
        --text-subtle: #737d93;

        --accent: #8b93ff;
        --accent-hover: #a6acff;
        --accent-soft: rgb(139 147 255 / 0.14);
        --accent-text: #0d1017;

        --success: #4ade80;
        --danger: #f87171;
        --danger-soft: rgb(248 113 113 / 0.1);
        --warning: #f4c56b;
        --warning-soft: rgb(244 197 107 / 0.08);
        --warning-border: rgb(244 197 107 / 0.3);

        --checker: #d5d9e2;
        --focus-ring: 0 0 0 3px rgb(139 147 255 / 0.35);
        --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
        --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px -20px rgb(0 0 0 / 0.7);
    }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

h1 {
    font-size: clamp(1.8rem, 1.3rem + 1.8vw, 2.4rem);
    font-weight: 750;
    letter-spacing: -0.025em;
}

h1:focus {
    outline: none;
}

a {
    color: var(--accent);
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

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

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.container {
    width: min(100% - 2rem, 1180px);
    margin-inline: auto;
}

.icon {
    flex: none;
}

/* ---------- Site layout ---------- */

.skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 100;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    top: 0.75rem;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: var(--header-height);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    font-size: 1.125rem;
    font-weight: 750;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 12px -4px rgb(99 102 241 / 0.6);
}

.site-nav {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
}

.site-nav a {
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s, background-color 0.15s;
}

.site-nav a:hover {
    color: var(--text);
    background: var(--surface-muted);
}

.site-nav a.active {
    color: var(--accent);
    background: var(--accent-soft);
}

.site-main {
    flex: 1;
    padding-block: 2rem 4rem;
}

.site-main:focus {
    outline: none;
}

.site-footer {
    border-top: 1px solid var(--border);
    padding-block: 1.5rem;
    color: var(--text-subtle);
    font-size: 0.875rem;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

/* ---------- Page elements ---------- */

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.eyebrow.is-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-subtle);
    font-size: 0.875rem;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--accent);
}

.page-header {
    max-width: 760px;
    margin-bottom: 1.75rem;
}

.page-lead {
    margin: 0.6rem 0 0;
    color: var(--text-muted);
    font-size: 1.075rem;
}

.message-page {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    max-width: 560px;
    padding-block: 3rem;
}

.message-page p {
    margin: 0;
    color: var(--text-muted);
}

/* ---------- Home ---------- */

.hero {
    max-width: 720px;
    padding-block: 2rem 1.5rem;
}

.hero h1 {
    margin-top: 1rem;
    font-size: clamp(2.1rem, 1.4rem + 2.6vw, 3.2rem);
}

.hero p {
    margin: 1rem 0 0;
    color: var(--text-muted);
    font-size: 1.15rem;
}

.section-title {
    margin: 2rem 0 1rem;
    color: var(--text-subtle);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.tool-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

a.tool-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    box-shadow: var(--shadow);
}

.tool-card h3 {
    font-size: 1.15rem;
}

.tool-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.tool-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
}

.tool-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 0.5rem;
}

.tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag {
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.tool-open {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 650;
}

a.tool-card:hover .tool-open .icon {
    transform: translateX(2px);
}

.tool-open .icon {
    transition: transform 0.15s ease;
}

.tool-card--soon {
    align-items: center;
    justify-content: center;
    min-height: 200px;
    border-style: dashed;
    background: transparent;
    box-shadow: none;
    text-align: center;
}

.tool-card--soon p {
    color: var(--text-subtle);
}

/* ---------- Cards ---------- */

.card {
    min-width: 0;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 2rem;
    margin-bottom: 0.9rem;
}

.card-heading h2 {
    font-size: 1.05rem;
    font-weight: 650;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn:hover:not(:disabled) {
    background: var(--surface-muted);
}

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

.btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-text);
}

.btn-primary:hover:not(:disabled) {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text);
}

.btn-sm {
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.chip {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

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

/* ---------- Form controls ---------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

fieldset.field {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
}

.field-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
}

legend.field-label {
    width: 100%;
    margin-bottom: 0.45rem;
}

.field-label output {
    color: var(--text-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.825rem;
}

fieldset.field .hint {
    margin-top: 0.45rem;
}

.hint.is-error {
    color: var(--danger);
}

.hint.is-info {
    color: var(--accent);
}

.input,
.textarea,
.select {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input {
    padding: 0.6rem 0.75rem;
}

.textarea {
    display: block;
    min-height: 7.5rem;
    padding: 0.75rem 0.9rem;
    line-height: 1.5;
    resize: vertical;
}

.textarea::placeholder {
    color: var(--text-subtle);
}

.select {
    padding: 0.55rem 2.25rem 0.55rem 0.75rem;
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
        linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

.segmented {
    display: flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-muted);
}

.segmented-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.segmented-option {
    flex: 1 1 0;
    padding: 0.42rem 0.5rem;
    border-radius: 7px;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.segmented-option:hover {
    color: var(--text);
}

.segmented-input:checked + .segmented-option {
    background: var(--surface-raised);
    color: var(--text);
    box-shadow: 0 1px 2px rgb(16 24 40 / 0.12), 0 0 0 1px var(--border);
}

.segmented-input:focus-visible + .segmented-option {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.color-input {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0.6rem 0.3rem 0.3rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.color-input:focus-within {
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

.color-input.is-disabled {
    opacity: 0.5;
}

.color-swatch {
    flex: none;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: none;
    cursor: pointer;
}

.color-swatch:focus-visible {
    outline: none;
}

.color-swatch::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-swatch::-webkit-color-swatch {
    border: 1px solid rgb(127 127 127 / 0.35);
    border-radius: 6px;
}

.color-swatch::-moz-color-swatch {
    border: 1px solid rgb(127 127 127 / 0.35);
    border-radius: 6px;
}

.color-hex {
    flex: 1;
    min-width: 0;
    padding: 0.25rem 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.color-hex:focus {
    outline: none;
}

.range {
    width: 100%;
    margin: 0.2rem 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 1rem;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.check input {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 1.25rem;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 0.925rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.dropzone:hover,
.dropzone:focus-within {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text);
}

.dropzone strong {
    color: var(--accent);
}

.dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ---------- Settings panels ---------- */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1.1rem 1.25rem;
}

.settings-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.settings-section h3,
.advanced summary {
    margin: 0 0 1rem;
    color: var(--text-subtle);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.settings-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.settings-heading h3 {
    margin: 0;
}

.advanced summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    list-style: none;
    cursor: pointer;
}

.advanced summary::-webkit-details-marker {
    display: none;
}

.advanced summary::before {
    content: "";
    width: 0.42rem;
    height: 0.42rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s;
}

.advanced[open] summary {
    margin-bottom: 1rem;
}

.advanced[open] summary::before {
    transform: rotate(45deg);
}

.advanced summary:hover {
    color: var(--text);
}

/* ---------- Feedback ---------- */

.notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 1.5rem;
    margin: 0.75rem 0 0;
    color: var(--success);
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
}

.notice.is-error {
    color: var(--danger);
}

/* Kept in the page while empty so screen readers announce what appears in it later. */
.notice:empty {
    min-height: 0;
    margin: 0;
}

.warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.6rem 0 0;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-sm);
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 0.85rem;
    line-height: 1.45;
}

.warning .icon {
    margin-top: 0.1rem;
}

/* ---------- Blazor ---------- */

.blazor-error-boundary {
    padding: 1rem 1rem 1rem 3.7rem;
    border-radius: var(--radius-sm);
    background: #b32121;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

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