/* ==========================================================================
   TimeWorked — base design system
   Shared by every page. Tokens, reset, layout chrome, typography, controls.
   ========================================================================== */

:root {
    /* Dark is the default identity of the site. */
    --bg-primary: #0d0d12;
    --bg-secondary: #14141c;
    --bg-tertiary: #1a1a26;
    --bg-hover: #22222e;
    --bg-cell: #18181f;
    --border: #2a2a3a;
    --border-strong: #3a3a4e;
    --border-focus: #4a6cf7;
    --text-primary: #e8e8ed;
    --text-secondary: #9898a8;
    --text-muted: #7a7a8e;
    --accent: #4a6cf7;
    --accent-hover: #5d7bf9;
    --accent-soft: rgba(74, 108, 247, 0.12);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --grid-header: #1e1e2a;
    --cell-even: #15151d;
    --cell-odd: #18181f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);

    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --radius: 8px;
    --radius-sm: 5px;
    --page-max: 1600px;
    --prose-max: 860px;
}

:root[data-theme="light"] {
    --bg-primary: #f6f7fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f8;
    --bg-hover: #e7eaf4;
    --bg-cell: #ffffff;
    --border: #dfe3ee;
    --border-strong: #c6ccdd;
    --border-focus: #3552d8;
    --text-primary: #16181f;
    --text-secondary: #545a6b;
    --text-muted: #767d90;
    --accent: #3552d8;
    --accent-hover: #2a43b8;
    --accent-soft: rgba(53, 82, 216, 0.10);
    --success: #16803c;
    --warning: #a35a05;
    --danger: #c62828;
    --grid-header: #eef1f8;
    --cell-even: #fafbfe;
    --cell-odd: #ffffff;
    --shadow: 0 1px 2px rgba(20, 25, 45, 0.08);
    --shadow-lg: 0 12px 32px rgba(20, 25, 45, 0.12);
}

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

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body > footer {
    margin-top: auto;
}

img,
svg {
    max-width: 100%;
}

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

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

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --------------------------------------------------------------- Skip link */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 200;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: 0 0 var(--radius) 0;
    font-size: 0.85rem;
    text-decoration: none;
}

.skip-link:focus {
    left: 0;
}

/* ------------------------------------------------------------------ Header */

.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: var(--page-max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    text-decoration: none;
    flex-shrink: 0;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Primary site navigation */
.site-nav {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    flex-wrap: wrap;
}

.nav-link {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.45rem 0.7rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    list-style: none;
}

.nav-link::-webkit-details-marker {
    display: none;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.site-nav > a[aria-current="page"],
.nav-link.is-section {
    color: var(--accent);
    background: var(--accent-soft);
}

.nav-menu[open] > .nav-link {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-menu[open] > .nav-link svg {
    transform: rotate(180deg);
}

/* The compact ☰ menu replaces the inline nav on small screens. */
.nav-compact {
    display: none;
    margin-left: auto;
}

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

.btn {
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-focus);
}

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

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

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

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

.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-icon {
    padding: 0.5rem;
}

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

input,
select,
textarea,
button {
    font-family: inherit;
}

.field-input,
.rate-input,
.currency-select {
    padding: 0.45rem 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg-cell);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.field-input:focus,
.rate-input:focus,
.currency-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.rate-input {
    width: 90px;
}

.currency-select {
    cursor: pointer;
}

/* ----------------------------------------------------------------- Content */

.content-section {
    max-width: var(--prose-max);
    margin: 4rem auto;
    padding: 0 1.5rem;
    width: 100%;
}

.content-section h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.25;
}

.content-section h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 2.5rem 0 0.75rem;
    line-height: 1.3;
}

.content-section h3 {
    font-size: 1.02rem;
    font-weight: 600;
    margin: 1.5rem 0 0.4rem;
}

.content-section p,
.content-section li {
    color: var(--text-secondary);
}

.content-section p {
    margin-bottom: 1rem;
}

.content-section ul,
.content-section ol {
    margin: 0 0 1rem 1.5rem;
}

.content-section li {
    margin-bottom: 0.5rem;
}

.lede {
    font-size: 1.05rem;
}

/* Cards used for features and cross-links */

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin: 2rem 0;
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-decoration: none;
    display: block;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

a.feature-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.feature-icon {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1;
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Callout */

.callout {
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}

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

/* Data tables inside prose */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 1.5rem 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg-secondary);
}

.data-table th {
    background: var(--grid-header);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: var(--bg-hover);
}

/* FAQ */

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

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

.faq-item h3 {
    margin: 0 0 0.4rem;
    font-size: 0.98rem;
}

.faq-item p:last-child {
    margin-bottom: 0;
}

/* kbd — note this styles the real element, so <kbd> works everywhere */

kbd {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.15rem 0.4rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 3px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ------------------------------------------------------------- Breadcrumbs */

.breadcrumbs {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}

.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
}

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

.crumb-sep {
    color: var(--border-strong);
}

/* ----------------------------------------------------------- Guide articles */

.guide {
    max-width: var(--prose-max);
    margin: 2.5rem auto 0;
    padding: 0 1.5rem;
    width: 100%;
}

.guide-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0.75rem 0 0;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--border);
}

.toc {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.35rem;
    margin: 0 0 2rem;
}

.toc h2 {
    font-size: 0.7rem !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 0.6rem !important;
}

.toc ol {
    margin: 0 0 0 1.1rem;
    padding: 0;
}

.toc li {
    margin-bottom: 0.3rem;
    font-size: 0.88rem;
}

.toc a {
    color: var(--text-secondary);
    text-decoration: none;
}

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

.guide + .content-section {
    /* The guide header already ends in a rule; do not add a second gap. */
    margin-top: 1.5rem;
}

.content-section h2[id],
.guide h2[id] {
    scroll-margin-top: 5rem;
}

.sources {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.sources li {
    margin-bottom: 0.35rem;
    color: var(--text-muted);
}

/* Key/value definition rows used in glossaries */

.deflist {
    margin: 1.5rem 0;
}

.deflist dt {
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1.1rem;
    font-size: 0.95rem;
}

.deflist dd {
    margin: 0.2rem 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

/* ------------------------------------------------------------------ Footer */

.footer {
    padding: 2.5rem 1.5rem 2rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4rem;
}

.footer-grid {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1.75rem 2rem;
}

.footer-col h2 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin: 0 0 0.65rem;
    font-weight: 600;
}

.footer-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-col li {
    margin-bottom: 0.35rem;
    font-size: 0.83rem;
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

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

.footer-note {
    max-width: 1100px;
    margin: 2rem auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    line-height: 1.6;
}

.footer-sep {
    color: var(--border-strong);
}

/* Legacy single-row footer links (kept for any page not yet regenerated) */
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 0.75rem;
    margin-bottom: 1rem;
}

/* ---------------------------------------------------------------- Utilities */

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

.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.muted {
    color: var(--text-muted);
}

/* Toast notifications */

.toast-stack {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    pointer-events: none;
    width: min(90vw, 420px);
}

.toast {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    color: var(--text-primary);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    pointer-events: auto;
    animation: toast-in 0.18s ease;
}

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

.toast.success {
    border-left-color: var(--success);
}

.toast button {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.toast button:hover {
    background: var(--bg-hover);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------- Menu button */

.menu {
    position: relative;
}

.menu > summary {
    list-style: none;
    cursor: pointer;
}

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

.menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    background: var(--bg-secondary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    min-width: 220px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.menu-panel-wide {
    min-width: 290px;
    max-width: min(340px, calc(100vw - 2rem));
    max-height: min(70vh, 620px);
    overflow-y: auto;
}

.menu-panel button,
.menu-panel a {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.82rem;
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    text-decoration: none;
    line-height: 1.35;
}

.menu-panel button:hover,
.menu-panel a:hover {
    background: var(--bg-hover);
}

.menu-panel a[aria-current="page"] {
    color: var(--accent);
    background: var(--accent-soft);
}

.menu-panel button small,
.menu-panel a small {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 400;
}

.menu-heading {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    padding: 0.5rem 0.6rem 0.25rem;
    margin: 0;
}

.menu-panel hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.25rem 0;
}

.menu-panel .danger {
    color: var(--danger);
}

/* --------------------------------------------------------------- Responsive */

@media (max-width: 900px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .site-nav {
        display: none;
    }

    .nav-compact {
        display: block;
    }

    .header-content {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .menu-panel-wide {
        position: fixed;
        right: 0.75rem;
        left: 0.75rem;
        top: 4rem;
        max-width: none;
        min-width: 0;
    }

    .content-section {
        margin: 2.5rem auto;
    }

    .content-section h1 {
        font-size: 1.6rem;
    }
}

@media (max-width: 620px) {
    /* Icon-only buttons in the header; the labels return on wider screens. */
    .header-actions .btn > span:not([data-theme-icon]) {
        display: none;
    }

    .header-actions .btn {
        padding: 0.5rem 0.65rem;
    }

    .logo span:last-child {
        font-size: 1rem;
    }
}

/* ------------------------------------------------------------------- Print */

@media print {
    .header,
    .footer,
    .content-section,
    .site-nav,
    .skip-link,
    .toast-stack,
    .no-print {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }
}

/* ---------------------------------------------------- Static content pages */

.doc-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.email-address {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    color: var(--accent);
    margin: 0.5rem 0 1rem;
    word-break: break-all;
}

.content-section .callout h2 {
    margin-top: 0;
    font-size: 1.05rem;
}
