/* base.css — Global reset, design tokens, typography, and shared UI components */

@import url('lightmode.css');

:root {
    --border-radius-small:   4px;
    --border-radius-default: 8px;
    --border-radius-pill:    999px;

    --font-size-xs:   0.75rem;
    --font-size-sm:   0.875rem;
    --font-size-base: 1rem;
    --font-size-lg:   1.25rem;
    --font-size-xl:   1.5rem;

    --shadow-intensity: 0.85;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    cursor: default;
}

[hidden] { display: none !important; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */

html {
    overflow-y: scroll;
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    margin: 0;
    line-height: 1.6;
    background: var(--color-background);
    padding: 40px 80px 150px 80px;
    color: var(--color-text-base);
    user-select: none;
}

.container {
    background: var(--color-background);
    width: 800px;
    margin: 0 auto;
}

h1 {
    margin-top: 3em;
    margin-bottom: 3em;
    color: var(--color-text-base);
    font-size: var(--font-size-base);
}

ul {
    list-style: none;
}

/* ── Links ──────────────────────────────────────────────────────────────────── */

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

a:hover {
    text-decoration: underline;
}

/* ── Input fields ───────────────────────────────────────────────────────────── */

input, textarea {
    cursor: text;
}

/* ── Breadcrumb ────────────────────────────────────────────────────────────── */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3em;
    margin-bottom: 3em;
    font-size: var(--font-size-sm);
    min-width: 0;
    overflow: hidden; /* final safety net if all shrink budgets are exhausted */
}

/* Ancestors shrink last — they give up space only after .bc-current is at its minimum */
.bc-ancestor {
    display: inline-block;
    padding: 2px 8px;
    background: var(--color-background-boxes);
    border: 1px solid var(--color-text-verysoft);
    border-radius: var(--border-radius-default);
    color: var(--color-text-soft);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 2ch; /* never collapse entirely — at least two chars remain visible */
    flex-shrink: 1;
    flex-basis: auto;
}

.bc-ancestor:hover {
    color: var(--color-text-base);
    border-color: var(--color-text-soft);
    text-decoration: none;
}

/* Separators are structural — never shrink, never truncate */
.bc-sep {
    color: var(--color-text-verysoft);
    white-space: nowrap;
    flex-shrink: 0;
    user-select: none;
}

/* Current page — wrapper is the visible box; label + suffix sit inside it */
.bc-current-wrapper {
    display: inline-flex;
    align-items: baseline;
    padding: 2px 8px;
    background: var(--color-background-boxes);
    border: 1px solid var(--color-text-soft);
    border-radius: var(--border-radius-default);
    color: var(--color-text-base);
    min-width: 0;
    flex-shrink: 2;
    max-width: 440px;
}

/* Label truncates inside the box */
.bc-current {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 4ch;
    flex-shrink: 1;
}

/* Suffix (e.g. " (Edit)") — inside the box, never truncated */
.bc-suffix {
    color: var(--color-text-soft);
    white-space: nowrap;
    flex-shrink: 0;
    padding-left: 4px;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */

.footer {
    border-top: 1px solid var(--color-text-verysoft);
    margin-top: 4em;
    padding-top: 1em;
    font-size: var(--font-size-xs);
    color: var(--color-text-soft);
}

.footer a {
    color: var(--color-text-soft);
}

/* ── Tables ─────────────────────────────────────────────────────────────────── */

table {
    width: 100%;
    border-collapse: collapse;
    border: none;
}

th,
td {
    border: none;
    padding: 15px;
    text-align: left;
    vertical-align: top;
}

/* ── Navigation ─────────────────────────────────────────────────────────────── */

.scrolltotop-button {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 25px;
    border-radius: 999px;
    background: var(--color-background-boxes);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-soft);
    text-decoration: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    opacity: 0;
    pointer-events: none; /* Prevents clicks when hidden */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: none;
}

.scrolltotop-button.visible {
    opacity: 1;
    pointer-events: auto;
}

.scrolltotop-button:hover {
    background: var(--color-highlight);
    color: var(--color-text-inverted);
    text-decoration: none;
}

/* ── Inputs ─────────────────────────────────────────────────────────────────── */

::placeholder {
    color: var(--color-text-verysoft);
}

/* ── Button Styles ──────────────────────────────────────────────────────────── */

button,
.button,
.button-small {
    display: inline-block;
    padding: 8px 16px;
    font-size: var(--font-size-sm);
    color: var(--color-text-base);
    background: var(--color-background-boxes);
    border: 1px solid var(--color-text-base);
    border-radius: var(--border-radius-default);
    font-family: inherit;
    line-height: 1.6;
    text-decoration: none;
    text-indent: 0;
}

button:hover,
.button:hover {
    background: var(--color-highlight);
    color: var(--color-text-inverted);
    text-decoration: none;
}

.button-small {
    margin-left: 2px;
    margin-right: 2px;
    padding: 0 8px;
    font-size: var(--font-size-xs);
    color: var(--color-text-soft);
    border-color: var(--color-text-soft);
}

.button-small:hover {
    background: var(--color-background-boxes);
    color: var(--color-text-base);
    border-color: var(--color-text-base);
    text-decoration: none;
}

.button:disabled,
.button-small:disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.delete-button {
    border-color: var(--color-delete);
    color: var(--color-delete);
}

.delete-button:hover {
    background: var(--color-delete);
    color: var(--color-text-inverted);
    border: 1px solid var(--color-delete);
}

.delete-button-confirm {
    background: var(--color-delete);
    color: var(--color-text-inverted);
    border: 1px solid var(--color-delete);
}

.delete-button-confirm:hover {
    background: var(--color-delete);
    color: var(--color-text-inverted);
    border: 1px solid var(--color-delete);
}

/* Icon-only copy button — text-indent hides label text while keeping it accessible */
.copy-button,
.copy-button:hover {
    border: none;
    border-radius: 0;
    padding: 0;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    align-self: center;
    text-indent: -999px;
    overflow: hidden;
    background-color: var(--color-text-base);
    mask-image: url('../img/copy.svg');
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
}

.copy-button.copied,
.copy-button.copied:hover {
    mask-image: url("../img/copied.svg");
}

/* ── Switches ───────────────────────────────────────────────────────────────── */

/* Hide the native checkbox — visual state comes from the mask-image swap below */
input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: var(--font-size-sm);
}

.switch-handle {
    width: 20px;
    aspect-ratio: 3/2;
    mask-image: url("../img/toggle-off.svg");
    mask-repeat: no-repeat;
    mask-size: cover;
    mask-position: center;
    background-color: var(--color-text-base);
}

.switch input[type="checkbox"]:checked + .switch-handle {
    mask-image: url("../img/toggle-on.svg");
}

/* ── Pill Buttons ───────────────────────────────────────────────────────────── */

.pill-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 1em;
}

.pill-button {
    display: inline-block;
    padding: 4px 12px;
    font-size: var(--font-size-sm);
    color: var(--color-text-base);
    background: var(--color-background-boxes);
    border: 1px solid var(--color-text-soft);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.15s;
}

.pill-button:hover {
    background: var(--color-text-verysoft);
    border-color: var(--color-text-base);
    text-decoration: none;
}

.pill-button.active {
    background: var(--color-highlight);
    color: var(--color-text-inverted);
    border-color: var(--color-highlight);
}

.pill-button.active:hover {
    background: var(--color-highlight);
    color: var(--color-text-inverted);
    border-color: var(--color-highlight);
}

/* ── Veil ───────────────────────────────────────────────────────────────────── */

/* Full-screen blur overlay — toggled by JS adding/removing .hidden */
body > #veil {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99;
}

body > #veil.hidden {
    display: none;
}

/* ── Shared View ────────────────────────────────────────────────────────────── */

.shared-notice {
    color: var(--color-success-text);
    padding: 1rem;
    border-radius: var(--border-radius-default);
    margin-top: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--color-success-text);
}

/* ── Error States ───────────────────────────────────────────────────────────── */

.error {
    color: var(--color-error-text);
    margin: 10px 0;
    padding: 10px;
    background-color: var(--color-error-background);
    border: 1px solid var(--color-error-border);
    border-radius: var(--border-radius-default);
}

/* ── Drop Overlay ───────────────────────────────────────────────────────────── */

.global-drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 50000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.global-drop-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.global-drop-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 64px;
    border: 3px dashed rgba(255, 255, 255, 0.6);
    border-radius: var(--border-radius-default);
    background: rgba(255, 255, 255, 0.07);
    text-align: center;
    pointer-events: none;
    transition: border-color 0.1s, background 0.1s;
}

.global-drop-overlay.drop-ready .global-drop-inner {
    border-color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.13);
}

.global-drop-icon {
    display: block;
    width: 48px;
    height: 48px;
    background-color: #fff;
    mask-image: url('../../img/upload.svg');
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    opacity: 0.85;
}

.global-drop-title {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: #fff;
}

.global-drop-hint {
    margin: 0;
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.02em;
}

.hidden {
    display: none !important;
}

/* ── Mobile ─────────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    html {
        font-size: var(--font-size-sm);
    }

    body {
        padding: 0;
    }

    .container {
        margin: 2em auto;
        padding: 0 1.5em;
    }

    h1 {
        margin-bottom: 1em;
    }

    .bc-current {
        max-width: 180px;
    }

    li {
        margin-bottom: 1.2em;
        padding-left: 0;
        text-indent: 0;
    }
}