/*
    tclient.com site styles.
    Palette source of truth: Theme/TclientTheme.cs. The :root block below mirrors it for custom CSS.
    Outside :root, use only var(--tc-*) or var(--mud-palette-*) - no hardcoded colors.
*/
:root {
    --tc-bg: #121417;
    --tc-surface: #1C1F24;
    --tc-surface-raised: #16191D;
    --tc-lines: #2E333A;
    --tc-text: #E8EAED;
    --tc-text-secondary: #A9B0BA;
    --tc-accent: #FF7A1A;
    --tc-accent-dark: #E5650A;
    --tc-on-accent: #121417;
    --tc-link: #FF9A50;
    --tc-success: #4ADE80;
    --tc-warning: #FACC15;
    --tc-error: #F87171;
    --tc-info: #60A5FA;
    --tc-mono: "Cascadia Code", Consolas, "Courier New", monospace;
    /* Print (cheat sheets): paper is white whatever the screen theme. */
    --tc-print-bg: #FFFFFF;
    --tc-print-text: #000000;
}

/* ---- Layout ---------------------------------------------------------- */

.tc-appbar {
    border-bottom: 1px solid var(--tc-lines);
}

.tc-brand {
    color: var(--tc-accent);
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 1px;
    text-decoration: none;
}

    .tc-brand span {
        color: var(--tc-text);
    }

.tc-drawer {
    border-right: 1px solid var(--tc-lines);
}

/* Sidebar: categories are <details> (no script needed), styled like MudNavGroup. The credit sits at the bottom. */
.tc-nav {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 48px);
}

.tc-nav-group > summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    list-style: none;
    color: var(--tc-text);
    font-weight: 500;
}

    .tc-nav-group > summary::-webkit-details-marker {
        display: none;
    }

    .tc-nav-group > summary:hover {
        background-color: var(--mud-palette-action-default-hover);
    }

.tc-nav-group[open] > summary {
    color: var(--tc-accent);
}

.tc-nav-chevron {
    transition: transform 0.15s;
}

.tc-nav-group[open] .tc-nav-chevron {
    transform: rotate(180deg);
}

.tc-nav-group .mud-nav-link {
    padding-left: 3.25rem;
}

.tc-powered {
    margin-top: auto;
    padding: 0.75rem 1.5rem;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: var(--tc-text-secondary);
}

.tc-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

    .tc-main > main {
        flex: 1 0 auto;
        outline: none;
    }

.tc-footer {
    text-align: center;
    padding: 1rem;
    border-top: 1px solid var(--tc-lines);
    background-color: var(--tc-surface-raised);
}

.tc-skip-link {
    position: absolute;
    left: -9999px;
    z-index: 2000;
    padding: 0.5rem 1rem;
    background: var(--tc-accent);
    color: var(--tc-on-accent);
}

    .tc-skip-link:focus {
        left: 1rem;
        top: 1rem;
    }

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

/* FocusOnNavigate moves focus to the page <h1> for screen readers; don't draw a ring around it. */
h1:focus,
h1:focus-visible,
main:focus {
    outline: none;
}

/* ---- Headings & links ------------------------------------------------ */

.tc-section-title {
    color: var(--tc-accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--tc-accent);
    padding-bottom: 0.3rem;
    margin-bottom: 0.75rem;
}

.tc-link-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

    .tc-link-list a {
        color: var(--tc-link);
        text-decoration: none;
    }

        .tc-link-list a:hover,
        .tc-link-list a:focus-visible {
            text-decoration: underline;
        }

/* ---- Tool sub-navigation (ToolTabs) ----------------------------------- */

.tool-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tool-tab {
    padding: 0.35rem 0.9rem;
    border: 1px solid var(--tc-lines);
    border-radius: 999px;
    color: var(--tc-text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: border-color 0.15s, color 0.15s;
}

    .tool-tab:hover {
        border-color: var(--tc-accent);
        color: var(--tc-text);
    }

    .tool-tab.active {
        background-color: var(--tc-accent);
        border-color: var(--tc-accent);
        color: var(--tc-on-accent);
        font-weight: 600;
    }

/* ---- Home: IP address hero ------------------------------------------ */

.tc-ip-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem 1rem;
    /* Fade in once, then pulse gently (disabled by the prefers-reduced-motion rule below). */
    animation: tc-fade-in 0.6s ease-out, tc-pulse 2s ease-in-out 0.6s infinite;
}

.tc-ip-value {
    color: var(--tc-accent);
    font-size: clamp(1.75rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: 1px;
    word-break: break-all;
}

@keyframes tc-pulse {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

@keyframes tc-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ---- Copy button (CopyButton + js/tclient.js) ------------------------- */

.tc-copy {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0.3rem;
    border: 1px solid var(--tc-lines);
    border-radius: 6px;
    background: transparent;
    color: var(--tc-text-secondary);
    cursor: pointer;
    vertical-align: middle;
}

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

    .tc-copy.tc-copied::after {
        content: "Copied";
        position: absolute;
        left: 50%;
        bottom: calc(100% + 4px);
        transform: translateX(-50%);
        padding: 2px 6px;
        border-radius: 4px;
        background: var(--tc-accent);
        color: var(--tc-on-accent);
        font-size: 0.75rem;
        white-space: nowrap;
    }

/* ---- Tool content ----------------------------------------------------- */

.tc-mono,
.tc-json-editor textarea {
    font-family: var(--tc-mono) !important;
    font-size: 0.9rem;
}

/* Monospace text fields: the value, not their label or helper text. */
.tc-mono input {
    font-family: var(--tc-mono) !important;
}

.tc-mono .mud-input-helper-text,
.tc-mono .mud-input-label {
    font-family: var(--mud-typography-default-family) !important;
}

.tc-json-editor textarea {
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.tc-wrap {
    word-break: break-all;
    white-space: normal;
}

.tc-pre {
    white-space: pre;
    font-size: 0.85em;
}

/* ---- Blazor error bar ------------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 1000;
    width: 100%;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    background: var(--tc-surface);
    color: var(--tc-text);
    border-top: 2px solid var(--tc-warning);
}

    #blazor-error-ui .reload {
        color: var(--tc-link);
    }

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

/* ---- Motion ----------------------------------------------------------- */

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

/* ---- Plain (non-interactive) forms on static pages -------------------------- */

.tc-inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.tc-input {
    flex: 1 1 260px;
    max-width: 420px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 4px;
    background: transparent;
    color: var(--tc-text);
    font: inherit;
}

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

    .tc-input::placeholder {
        color: var(--tc-text-secondary);
    }

/* Visually hidden, still read by screen readers. */
.tc-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* File picker (label wraps a visually hidden <input type=file>). */
.tc-file-drop {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: 2px dashed var(--tc-lines);
    border-radius: 8px;
    color: var(--tc-text);
    cursor: pointer;
}

    .tc-file-drop:hover,
    .tc-file-drop:focus-within {
        border-color: var(--tc-accent);
        color: var(--tc-accent);
    }

/* ---- Password tools ------------------------------------------------------- */

.tc-key-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    border-top: 1px solid var(--tc-lines);
}

.tc-password-output {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--tc-lines);
    border-radius: 6px;
    font-size: 1.25rem;
    min-height: 3.5rem;
}

.tc-toggle-selected {
    background-color: var(--tc-accent) !important;
    color: var(--tc-on-accent) !important;
}

/* ---- Security tools ------------------------------------------------------- */

/* Decoded JSON / PEM output: monospace, wraps long base64 lines. */
.tc-code {
    margin: 0;
    font-family: var(--tc-mono);
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* PEM keeps its 64-character lines; scroll rather than re-wrap. */
.tc-code.tc-pem {
    white-space: pre;
    overflow-x: auto;
}

/* Security headers letter grade: dark text on a status color (all >= 7:1). */
.tc-grade {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 8px;
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--tc-on-accent);
    background: var(--tc-error);
}

    .tc-grade[data-grade="good"] {
        background: var(--tc-success);
    }

    .tc-grade[data-grade="fair"] {
        background: var(--tc-warning);
    }

/* Header names in the security headers tables stay on one line. */
.tc-header-name {
    white-space: nowrap;
}

/* Standards checks in a certificate card: a native <details> so it works on every page. */
.tc-lint > summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* Label column of the certificate details table. */
.tc-cert-label {
    width: 200px;
}

/* ---- Encoding & text tools ------------------------------------------------ */

/* "Copy link" (ShareLinkButton): a copy button with a label. */
.tc-copy.tc-share {
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    font: inherit;
    font-size: 0.85rem;
}

/* Changed characters in before/after views (URL encoder). Dark text on the accent: 7.1:1. */
mark.tc-changed {
    background-color: var(--tc-accent);
    color: var(--tc-on-accent);
    border-radius: 2px;
}

/* Text Diff. Tints are mixed from the status colors, so text stays #E8EAED on a dark background (>= 5:1). */
.tc-diff-scroll {
    max-height: 70vh;
    overflow: auto;
}

.tc-diff {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-family: var(--tc-mono);
    font-size: 0.85rem;
}

    .tc-diff th {
        text-align: left;
        padding: 0.3rem 0.5rem;
        border-bottom: 1px solid var(--tc-lines);
        color: var(--tc-text-secondary);
        font-family: var(--mud-typography-default-family);
        font-weight: 500;
    }

    .tc-diff td {
        padding: 0.05rem 0.5rem;
        vertical-align: top;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    .tc-diff .tc-diff-num {
        width: 3.5rem;
        text-align: right;
        color: var(--tc-text-secondary);
        user-select: none;
    }

.tc-diff-del {
    background-color: color-mix(in srgb, var(--tc-error) 16%, transparent);
}

.tc-diff-ins {
    background-color: color-mix(in srgb, var(--tc-success) 14%, transparent);
}

.tc-diff-hunk {
    color: var(--tc-info);
}

.tc-diff-empty {
    background-color: var(--tc-surface-raised);
}

mark.tc-diff-word-del,
mark.tc-diff-word-ins {
    color: var(--tc-text);
    border-radius: 2px;
}

mark.tc-diff-word-del {
    background-color: color-mix(in srgb, var(--tc-error) 42%, transparent);
}

mark.tc-diff-word-ins {
    background-color: color-mix(in srgb, var(--tc-success) 38%, transparent);
}

.tc-diff-gap td {
    text-align: center;
    color: var(--tc-text-secondary);
    background-color: var(--tc-surface-raised);
}

/* Regex Tester matches: alternating tints so neighbouring matches are distinguishable (text stays #E8EAED). */
mark.tc-match {
    color: var(--tc-text);
    background-color: color-mix(in srgb, var(--tc-accent) 38%, transparent);
    border-radius: 2px;
    outline: 1px solid var(--tc-accent);
}

    mark.tc-match.tc-match-alt {
        background-color: color-mix(in srgb, var(--tc-info) 34%, transparent);
        outline-color: var(--tc-info);
    }

/* Markdown Preview: rendered (sanitized) content. */
.tc-markdown {
    line-height: 1.6;
    overflow-wrap: anywhere;
}

    .tc-markdown > :first-child {
        margin-top: 0;
    }

    .tc-markdown h1, .tc-markdown h2, .tc-markdown h3, .tc-markdown h4 {
        margin: 1.2em 0 0.5em;
        line-height: 1.25;
    }

    .tc-markdown h1 { font-size: 1.8rem; border-bottom: 1px solid var(--tc-lines); padding-bottom: 0.3em; }
    .tc-markdown h2 { font-size: 1.45rem; border-bottom: 1px solid var(--tc-lines); padding-bottom: 0.3em; }
    .tc-markdown h3 { font-size: 1.2rem; }

    .tc-markdown p, .tc-markdown ul, .tc-markdown ol, .tc-markdown blockquote, .tc-markdown table, .tc-markdown pre {
        margin: 0 0 1em;
    }

    .tc-markdown ul, .tc-markdown ol {
        padding-left: 2em;
    }

    .tc-markdown a {
        color: var(--tc-link);
    }

    .tc-markdown code {
        font-family: var(--tc-mono);
        font-size: 0.9em;
        padding: 0.1em 0.35em;
        border-radius: 4px;
        background: var(--tc-surface-raised);
    }

    .tc-markdown pre {
        padding: 0.8em 1em;
        overflow-x: auto;
        border-radius: 6px;
        background: var(--tc-surface-raised);
        border: 1px solid var(--tc-lines);
    }

        .tc-markdown pre code {
            padding: 0;
            background: none;
        }

    .tc-markdown blockquote {
        padding: 0 1em;
        color: var(--tc-text-secondary);
        border-left: 3px solid var(--tc-accent);
    }

    .tc-markdown table {
        border-collapse: collapse;
    }

    .tc-markdown th, .tc-markdown td {
        padding: 0.35em 0.8em;
        border: 1px solid var(--tc-lines);
    }

    .tc-markdown img {
        max-width: 100%;
    }

    .tc-markdown hr {
        border: 0;
        border-top: 1px solid var(--tc-lines);
    }

    .tc-markdown .task-list-item {
        list-style: none;
    }

        .tc-markdown .task-list-item input {
            margin: 0 0.4em 0 -1.4em;
        }

/* ---- Robocopy Command Builder --------------------------------------------- */

/* The command stays in view while scrolling the builder (desktop); stacked normally on small screens. */
@media (min-width: 960px) {
    .tc-sticky {
        position: sticky;
        top: 64px;
        z-index: 2;
    }
}

.tc-command {
    font-size: 0.9rem;
    max-height: 40vh;
    overflow: auto;
}

.tc-switch-row {
    padding: 0.25rem 0.5rem;
    border-left: 3px solid transparent;
    border-bottom: 1px solid var(--tc-lines);
}

    .tc-switch-row.tc-danger {
        border-left-color: var(--tc-error);
    }

.tc-switch-name {
    font-family: var(--tc-mono);
    font-weight: 600;
    color: var(--tc-link);
    background: none;
    border: 0;
    padding: 0 0.25rem;
    cursor: pointer;
    text-decoration: underline dotted;
}

    .tc-switch-name:hover {
        text-decoration: underline;
    }

.tc-switch-summary {
    color: var(--tc-text-secondary);
    font-size: 0.9rem;
}

.tc-switch-param {
    padding: 0.25rem 0 0.5rem 2.75rem;
}

.tc-findings {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tc-finding {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.3rem;
    border: 1px solid var(--tc-lines);
    border-left-width: 3px;
    border-radius: 4px;
    font-size: 0.875rem;
}

    .tc-finding[data-level="error"],
    .tc-finding[data-level="danger"] {
        border-left-color: var(--tc-error);
    }

    .tc-finding[data-level="warning"] {
        border-left-color: var(--tc-warning);
    }

    .tc-finding[data-level="info"] {
        border-left-color: var(--tc-info);
    }

.tc-ref-entry {
    border-bottom: 1px solid var(--tc-lines);
}

.tc-ref-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 100%;
    padding: 0.4rem 0.25rem;
    background: none;
    border: 0;
    color: var(--tc-text);
    text-align: left;
    font: inherit;
    cursor: pointer;
}

    .tc-ref-head:hover {
        background-color: var(--mud-palette-action-default-hover);
    }

.tc-ref-body {
    padding: 0.25rem 0.5rem 0.75rem 2rem;
}

.tc-ref-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 0.75rem;
    margin: 0;
    font-size: 0.875rem;
}

    .tc-ref-facts dt {
        color: var(--tc-text-secondary);
    }

    .tc-ref-facts dd {
        margin: 0;
        overflow-wrap: anywhere;
    }

.tc-flag {
    display: inline-block;
    margin-right: 0.75rem;
}

.tc-ref-notes {
    margin: 0;
    padding-left: 1.1rem;
}

.tc-gotchas code {
    font-family: var(--tc-mono);
    font-size: 0.85em;
}

/* ---- Command reference tables (CommandReferenceTable: Shell Translator) ---- */

.tc-xref-group {
    margin-top: 1rem;
}

.tc-xref-heading .tc-ref-head {
    font-size: 1.1rem;
    font-weight: 600;
}

.tc-xref-count {
    margin-left: 0.25rem;
    padding: 0 0.5rem;
    border: 1px solid var(--tc-lines);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--tc-text-secondary);
}

.tc-collapsed {
    display: none;
}

.tc-print-only {
    display: none;
}

.tc-xref {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

    .tc-xref th,
    .tc-xref td {
        padding: 0.45rem 0.6rem;
        text-align: left;
        vertical-align: top;
        overflow-wrap: anywhere;
    }

    .tc-xref thead th {
        color: var(--tc-text-secondary);
        font-weight: 500;
        border-bottom: 1px solid var(--tc-lines);
    }

    .tc-xref .tc-xref-task {
        width: 22%;
        font-weight: 500;
    }

    .tc-xref-row th,
    .tc-xref-row td {
        border-top: 1px solid var(--tc-lines);
    }

    .tc-xref code {
        font-family: var(--tc-mono);
        font-size: 0.875rem;
        color: var(--tc-text);
        white-space: pre-wrap;
    }

.tc-xref-cell {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    justify-content: space-between;
}

.tc-xref-detail,
.tc-xref-note-text,
.tc-xref-platform {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--tc-text-secondary);
}

.tc-xref-missing {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--tc-text-secondary);
}

/* The gotcha: the reason the page exists, so it's easy to scan for. */
.tc-xref-gotcha td {
    padding: 0.35rem 0.6rem 0.6rem;
    font-size: 0.875rem;
    border-left: 3px solid var(--tc-warning);
    background-color: color-mix(in srgb, var(--tc-warning) 7%, transparent);
}

    .tc-xref-gotcha td strong {
        color: var(--tc-warning);
    }

/* Narrow screens: each row becomes a card with labelled cells. */
@media (max-width: 700px) {
    .tc-xref thead {
        display: none;
    }

    .tc-xref,
    .tc-xref tbody,
    .tc-xref tr,
    .tc-xref th,
    .tc-xref td {
        display: block;
        width: 100% !important;
    }

    .tc-xref td.tc-print-only {
        display: none;
    }

    .tc-xref-row td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        color: var(--tc-text-secondary);
    }
}

/* ---- Print: a clean cheat sheet (no site chrome, everything expanded, all columns) ---- */
@media print {
    :root {
        --mud-palette-background: var(--tc-print-bg) !important;
        --mud-palette-surface: var(--tc-print-bg) !important;
        --mud-palette-text-primary: var(--tc-print-text) !important;
        --mud-palette-text-secondary: var(--tc-print-text) !important;
        --tc-text: var(--tc-print-text);
        --tc-text-secondary: var(--tc-print-text);
        --tc-lines: var(--tc-print-text);
    }

    body,
    .mud-main-content,
    .mud-paper {
        background: var(--tc-print-bg) !important;
        color: var(--tc-print-text) !important;
    }

    .mud-appbar,
    .mud-drawer,
    .tc-footer,
    .tool-tabs,
    .tc-skip-link,
    .tc-no-print,
    .tc-copy,
    #blazor-error-ui {
        display: none !important;
    }

    .mud-main-content {
        padding: 0 !important;
        margin: 0 !important;
    }

    .tc-collapsed,
    .tc-print-only {
        display: block !important;
    }

    .tc-xref td.tc-print-only,
    .tc-xref th.tc-print-only {
        display: table-cell !important;
    }

    .tc-xref-gotcha td {
        background: none;
        border-left-color: var(--tc-print-text);
    }

        .tc-xref-gotcha td strong {
            color: var(--tc-print-text);
        }

    .tc-xref-row {
        break-inside: avoid;
    }

    .tc-xref-group h2 {
        break-after: avoid;
    }
}

/* Shell Translator: the key differences list. */
.tc-differences {
    display: grid;
    grid-template-columns: minmax(12rem, 1fr) 3fr;
    gap: 0.4rem 1rem;
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
}

    .tc-differences dt {
        font-weight: 600;
    }

    .tc-differences dd {
        margin: 0;
        color: var(--tc-text-secondary);
    }

@media (max-width: 700px) {
    .tc-differences {
        grid-template-columns: 1fr;
    }

        .tc-differences dd {
            margin-bottom: 0.5rem;
        }
}

@media print {
    .mud-paper:has(> .tc-print-hide-card) {
        display: none !important;
    }
}
