/* Staff history page and the homepage "Currently" block (docs/history.md).
   Built on the site's variables (portfolio.css / theme.css). Role colours
   come from the role types (--role). */

.history .section-head {
    margin-bottom: calc(28px * var(--space-scale));
}

/* ---------- Summary ---------- */

.history-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: calc(16px * var(--space-scale));
    margin: 0 0 calc(36px * var(--space-scale));
}

.history-summary div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    padding: calc(18px * var(--space-scale)) calc(22px * var(--space-scale));
    display: flex;
    flex-direction: column-reverse;
}

.history-summary dt {
    color: var(--text-muted);
    font-size: 0.9em;
}

.history-summary dd {
    margin: 0;
    font-size: 2em;
    font-weight: 700;
    color: var(--text-strong);
    line-height: 1.2;
}

/* ---------- Filters ---------- */

.history-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
    margin: 0 0 calc(24px * var(--space-scale));
}

.history-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-filter {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font: inherit;
    font-size: 0.9em;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
}

.history-filter:hover {
    color: var(--text);
    border-color: var(--accent-bright);
}

.history-filter[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent-bright);
    color: var(--text-strong);
}

.history-filter:focus-visible,
.history-server-filter select:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 2px;
}

.role-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--role);
}

.history-server-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.9em;
}

.history-server-filter select {
    font: inherit;
    padding: 6px 10px;
    border-radius: calc(8px * var(--radius-scale));
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

/* ---------- Overview (lanes) ---------- */

.history-overview {
    margin: 0 0 calc(44px * var(--space-scale));
}

.history-lanes {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    padding: 14px 18px 18px;
    --label: 150px;
}

.history-axis,
.history-lane {
    display: grid;
    grid-template-columns: var(--label) 1fr;
    gap: 14px;
    align-items: center;
}

.history-axis .history-track {
    height: 22px;
    border-bottom: 1px solid var(--border);
}

.history-year {
    position: absolute;
    bottom: 4px;
    transform: translateX(-50%);
    font-size: 0.75em;
    color: var(--text-muted);
}

.history-lane {
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
}

.history-lane:last-of-type {
    border-bottom: 0;
}

.history-lane-name {
    color: var(--text);
    font-weight: 600;
    font-size: 0.92em;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.history-lane-name:hover {
    color: var(--accent-bright);
}

.history-track {
    position: relative;
    min-height: 24px;
}

.history-bar,
.history-marker {
    position: absolute;
    padding: 0;
    border: 0;
    cursor: pointer;
    background: var(--role, var(--accent-bright));
}

.history-bar {
    height: 12px;
    border-radius: 6px;
    box-shadow: 0 0 0 2px var(--surface);
}

/* Still held: fades out towards today, with an arrow. */
.history-bar.current {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    background: linear-gradient(to right, var(--role, var(--accent-bright)) 70%, transparent);
}

.history-bar.current::after {
    content: "";
    position: absolute;
    right: -6px;
    top: 1px;
    border-left: 7px solid var(--role, var(--accent-bright));
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    opacity: 0.8;
}

.history-marker {
    width: 12px;
    height: 12px;
    margin-left: -6px;
    transform: rotate(45deg);
    background: var(--text-strong);
    box-shadow: 0 0 0 2px var(--surface);
}

.history-bar:hover,
.history-bar:focus-visible,
.history-marker:hover,
.history-marker:focus-visible {
    outline: 2px solid var(--text-strong);
    outline-offset: 2px;
    z-index: 2;
}

.history-today {
    position: absolute;
    top: 14px;
    bottom: 18px;
    left: calc(18px + var(--label) + 14px + (100% - 36px - var(--label) - 14px) * var(--x) / 100);
    width: 0;
    border-left: 1px dashed var(--accent-bright);
    pointer-events: none;
}

.history-today span {
    position: absolute;
    top: -2px;
    left: 4px;
    font-size: 0.7em;
    color: var(--accent-bright);
    white-space: nowrap;
}

.history-tip {
    position: absolute;
    z-index: 5;
    max-width: 280px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    padding: 8px 12px;
    font-size: 0.88em;
    color: var(--text-muted);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.history-tip strong {
    color: var(--text-strong);
    display: block;
}

/* ---------- Server cards ---------- */

.history-servers {
    display: grid;
    gap: calc(24px * var(--space-scale));
}

.history-server {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    padding: calc(22px * var(--space-scale)) calc(26px * var(--space-scale));
    scroll-margin-top: 90px;
}

.history-server header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: calc(16px * var(--space-scale));
}

.history-server h2 {
    margin: 0;
    font-size: 1.35em;
    flex: 1;
}

.history-server-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface-alt);
    object-fit: contain;
    image-rendering: pixelated;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-muted);
}

.history-server-link {
    color: var(--accent-bright);
    font-weight: 600;
    font-size: 0.92em;
}

.history-entries {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Progression: a line through the entries, newest at the top. */
.history-entries::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 8px;
    bottom: 8px;
    border-left: 2px solid var(--border);
}

.history-entry {
    position: relative;
    padding: 0 0 calc(20px * var(--space-scale)) 28px;
    scroll-margin-top: 110px;
    border-radius: calc(8px * var(--radius-scale));
}

.history-entry:last-child {
    padding-bottom: 0;
}

.history-entry::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--role, var(--accent-bright));
    box-shadow: 0 0 0 3px var(--surface);
}

.history-entry.milestone::before {
    border-radius: 2px;
    transform: rotate(45deg);
    background: var(--text-strong);
}

.history-entry.flash {
    animation: history-flash 1.6s ease;
}

@keyframes history-flash {
    0%, 40% { background: var(--surface-alt); }
    100% { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .history-entry.flash { animation: none; background: var(--surface-alt); }
}

.history-entry-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 12px;
}

.history-entry h3 {
    margin: 0;
    font-size: 1.08em;
}

.history-entry.milestone h3 {
    font-style: italic;
}

.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75em;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--role, var(--border));
    color: var(--text);
}

.role-chip::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--role, var(--accent-bright));
}

.milestone-chip::before {
    border-radius: 1px;
    transform: rotate(45deg);
    background: var(--text-strong);
}

.history-when {
    color: var(--text-muted);
    font-size: 0.9em;
    margin: 4px 0 0;
}

.history-text {
    margin-top: 8px;
}

.history-text > :first-child { margin-top: 0; }
.history-text > :last-child { margin-bottom: 0; }

.history-image {
    display: block;
    max-width: min(100%, 520px);
    border-radius: calc(8px * var(--radius-scale));
    border: 1px solid var(--border);
    margin-top: 10px;
}

.history-overlap {
    font-size: 0.88em;
    color: var(--text-muted);
    margin: 8px 0 0;
}

.history-overlap a,
.history-link {
    color: var(--accent-bright);
}

.history-friends {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.85em;
    color: var(--text-muted);
}

.history-friends ul {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.history-friends li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
}

.history-friends a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
}

.history-friends a:hover span {
    color: var(--accent-bright);
}

.history-friends img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    image-rendering: pixelated;
    background: var(--surface-alt);
}

.history-none,
.history-empty {
    color: var(--text-muted);
}

/* ---------- Homepage "Currently" ---------- */

.current-role-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.current-role-list li {
    display: flex;
    gap: 12px;
    align-items: baseline;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(10px * var(--radius-scale));
    padding: 14px 18px;
}

.current-role-list .role-dot {
    flex: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--role, var(--accent-bright));
}

.current-role-list a {
    color: var(--accent-bright);
}

/* ---------- Phones: lane names above their bars ---------- */

@media (max-width: 700px) {
    .history-lanes {
        --label: 0px;
        padding: 12px;
    }

    .history-axis,
    .history-lane {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .history-axis > span:first-child {
        display: none;
    }

    .history-lane-name {
        font-size: 0.85em;
    }

    .history-today {
        left: calc(12px + (100% - 24px) * var(--x) / 100);
        top: 12px;
        bottom: 12px;
    }

    .history-year:nth-child(even) {
        display: none;
    }

    .history-server {
        padding: 18px;
    }
}
