@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    --bg:      #dedad1;   /* concrete base */
    --surface: #e8e4db;   /* panel surface */
    --white:   #f5f2eb;   /* lightest panel */
    --fascia:  #161411;   /* dark header / fascia */
    --ink:     #1c1a17;
    --muted:   #56514c;
    --joint:   #b8b2a6;   /* construction joint */
    --red:     #c41000;   /* Bauhaus red */
    --yellow:  #d9a800;   /* Bauhaus yellow */
    --blue:    #0f3d8a;   /* Bauhaus blue */
}

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

body {
    margin: 0;
    font-family: 'Space Grotesk', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.65;
}

h1, h2, h3 {
    margin: 0;
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.025em;
    color: var(--ink);
}

p { margin: 0; color: var(--muted); line-height: 1.75; }

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

a {
    color: var(--blue);
    text-decoration: none;
    transition: color 0.12s;
}
a:hover { color: var(--red); }

img { display: block; max-width: 100%; }

/* ════════════════════════════════════
   HEADER
════════════════════════════════════ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--fascia);
    border-bottom: 3px solid var(--red);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: stretch;
    height: 50px;
    padding: 0 24px;
}

.brand {
    display: flex;
    align-items: center;
    color: #fff;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.76rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    padding-right: 24px;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    transition: color 0.12s;
    flex-shrink: 0;
}
.brand:hover { color: var(--yellow); }

.site-nav {
    display: flex;
    align-items: stretch;
    margin-left: auto;
}

.site-nav a {
    display: flex;
    align-items: center;
    padding: 0 18px;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    transition: color 0.12s, background 0.12s;
}
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.site-nav a.active { color: #fff; background: var(--red); }

/* ════════════════════════════════════
   PAGE WRAP
════════════════════════════════════ */

.page-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

main > * + .panel,
main > * + .panel-row,
main > * + .panel-row-2,
main > * + .panel-row-asym,
main > * + .card-grid,
main > * + section {
    margin-top: 24px;
}

/* ════════════════════════════════════
   INTRO BLOCK (home page)
════════════════════════════════════ */

.intro {
    background: var(--white);
    border: 1px solid var(--joint);
}

.intro-no-portrait {
    grid-template-columns: 1fr;
    min-height: auto;
}

.intro-text {
    padding: 48px;
    border-right: 1px solid var(--joint);
}

.intro-text h1 {
    font-size: 1.6rem;
    margin: 12px 0 20px;
}

.intro-text p { margin-top: 14px; }

.intro-portrait {
    overflow: hidden;
}
.intro-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.65);
}
.intro-portrait-inline {
    float: right;
    width: 110px;
    height: 110px;
    object-fit: cover;
    object-position: center top;
    border-radius: 50%;
    margin: 0 0 16px 28px;
}

/* ════════════════════════════════════
   SECTION PLATE (label)
════════════════════════════════════ */

.plate {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--red);
    margin-bottom: 10px;
}

/* ════════════════════════════════════
   PANEL LAYOUTS
════════════════════════════════════ */

.panel-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
}

.panel-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
}

.panel-row-asym {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2px;
}

.panel {
    background: var(--white);
    border: 1px solid var(--joint);
    padding: 32px;
}

.panel h2 {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    margin-bottom: 12px;
}

.panel h3 {
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.panel p + p { margin-top: 12px; }

.panel-dark {
    background: var(--fascia);
    border-color: var(--fascia);
}
.panel-dark .plate { color: var(--yellow); }
.panel-dark h2 { color: #fff; }
.panel-dark p { color: rgba(255, 255, 255, 0.55); }

/* ════════════════════════════════════
   PAGE HEADING (inner pages)
════════════════════════════════════ */

.page-heading {
    font-size: clamp(2rem, 5vw, 3.4rem);
    margin-bottom: 14px;
}
.page-heading--sm {
    font-size: 1.4rem;
    margin-bottom: 14px;
}

.text-prose { max-width: none; }

/* ════════════════════════════════════
   TIMELINE
════════════════════════════════════ */

.timeline { margin-top: 20px; }

.timeline-item {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 20px;
    padding: 18px 0;
    border-top: 1px solid var(--joint);
}
.timeline-item:first-child { border-top: none; padding-top: 0; }

.timeline-year {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    color: var(--muted);
    padding-top: 5px;
    line-height: 1.6;
}

.timeline-role {
    display: block;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--ink);
    margin-bottom: 2px;
}

.timeline-place {
    display: block;
    color: var(--blue);
    font-weight: 500;
    font-size: 0.88rem;
    margin-bottom: 6px;
}

.timeline-detail { font-size: 0.9rem; }

/* ════════════════════════════════════
   BUTTONS
════════════════════════════════════ */

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 11px 20px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn-primary {
    background: var(--fascia);
    color: #fff;
    border: 1px solid var(--fascia);
}
.btn-primary:hover { background: var(--red); border-color: var(--red); color: #fff; }

.btn-secondary {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--joint);
}
.btn-secondary:hover { border-color: var(--ink); }

/* ════════════════════════════════════
   CARDS
════════════════════════════════════ */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2px;
}
.card-grid--single {
    grid-template-columns: 1fr;
}
.preprint-authors {
    font-size: 0.82rem;
    color: var(--muted);
    font-style: italic;
}
.preprint-abstract {
    font-size: 0.85rem;
    line-height: 1.65;
    color: var(--ink);
}

.card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--joint);
    text-decoration: none;
    transition: background 0.12s;
    color: inherit;
}
a.card:hover {
    background: var(--white);
    border-left: 3px solid var(--red);
    transform: translateY(-2px);
    transition: background 0.12s, border 0.12s, transform 0.15s;
}

.card h3 { font-size: 1rem; }
.card p { font-size: 0.88rem; }
.card .plate { margin-bottom: 6px; }

.card-link {
    margin-top: auto;
    padding-top: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--blue);
}

/* ════════════════════════════════════
   PILL LIST (research themes)
════════════════════════════════════ */

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

.pill {
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--joint);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ════════════════════════════════════
   CONTACT
════════════════════════════════════ */

.contact-list { margin-top: 20px; }

.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }

.text-mono-sm {
    margin-top: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
}

.contact-item {
    display: grid;
    grid-template-columns: 100px 1fr;
    padding: 14px 0;
    border-top: 1px solid var(--joint);
    gap: 12px;
    align-items: start;
}
.contact-item:first-child { border-top: none; padding-top: 0; }

.contact-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding-top: 2px;
}

.contact-value { color: var(--ink); font-weight: 500; }
.contact-value a { color: var(--ink); }
.contact-value a:hover { color: var(--red); }

/* ════════════════════════════════════
   IMAGE PANEL (pure image, no padding)
════════════════════════════════════ */

.image-panel {
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--joint);
}

.map-panel {
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--joint);
}
.map-panel iframe {
    width: 100%;
    height: 100%;
    min-height: 280px;
    display: block;
    border: 0;
}
.image-panel img {
    width: 100%;
    height: 100%;
    min-height: 200px;
    object-fit: cover;
    display: block;
    filter: saturate(0.7);
}
/* Small humour image — right-aligned, contained */
.misc-image-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0 24px;
    margin: 0;
    gap: 10px;
}
.misc-image-link {
    display: block;
    transition: transform 0.16s ease;
}
.misc-image-link:hover {
    transform: translateY(-2px);
}
.misc-image-wrap img {
    max-width: 360px;
    width: 100%;
    display: block;
    border: 1px solid var(--joint);
}

/* ════════════════════════════════════
   PANEL IMAGE (image inside padded panel)
════════════════════════════════════ */

.panel-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    margin-top: 16px;
}

/* ════════════════════════════════════
   CANVAS / GAME
════════════════════════════════════ */

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--joint);
    background: var(--bg);
    margin-top: 16px;
}

.canvas-caption {
    margin-top: 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    color: var(--muted);
}

/* ════════════════════════════════════
   FOOTER
════════════════════════════════════ */

.footer {
    margin-top: 32px;
    padding-top: 18px;
    border-top: 2px solid var(--fascia);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.footer p,
.footer span {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0;
}

/* ════════════════════════════════════
   RESPONSIVE
════════════════════════════════════ */

@media (max-width: 900px) {
    .intro { grid-template-columns: 1fr; min-height: auto; }
    .intro-portrait { height: 260px; }
    .intro-text { border-right: none; border-bottom: 1px solid var(--joint); }
    .panel-row { grid-template-columns: 1fr; }
    .panel-row-2 { grid-template-columns: 1fr; }
    .panel-row-asym { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .page-wrap { padding: 16px 14px 48px; }
    .header-inner { padding: 0 14px; }
    .brand { font-size: 0.66rem; padding-right: 14px; }
    .site-nav a { padding: 0 12px; font-size: 0.64rem; }
    .intro-text { padding: 28px; }
    .panel { padding: 24px; }
    .timeline-item { grid-template-columns: 1fr; gap: 4px; }
    .contact-item { grid-template-columns: 1fr; gap: 4px; }
}

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

/* ════════════════════════════════════
   U6 DEPARTURE BOARD
════════════════════════════════════ */

.u6-row {
    display: grid;
    grid-template-columns: 32px 1fr 52px 64px;
    gap: 10px;
    align-items: center;
    padding: 9px 0;
    border-top: 1px solid var(--joint);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
}
.u6-row:first-child { border-top: none; padding-top: 0; }

.u6-row.u6-now .u6-label { color: var(--red); font-weight: 500; }

.u6-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #006cb7;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 2px 4px;
    width: 28px;
}

.u6-dest  { color: var(--ink); font-size: 0.78rem; font-family: 'Space Grotesk', system-ui, sans-serif; }
.u6-hhmm  { color: var(--muted); text-align: right; }
.u6-label { color: var(--ink); text-align: right; font-weight: 500; }
.u6-label.u6-late { color: #d97000; }

.u6-stamp {
    margin-top: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.62rem;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.u6-msg {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--muted);
}

/* ════════════════════════════════════
   VISUALISATION TABS
════════════════════════════════════ */

.viz-tabs {
    display: flex;
    border-bottom: 2px solid var(--fascia);
    margin-bottom: 0;
    flex-wrap: wrap;
}

.viz-tab {
    padding: 10px 18px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-right: 1px solid var(--joint);
    transition: background 0.12s, color 0.12s;
}
.viz-tab:hover  { color: var(--ink); background: var(--surface); }
.viz-tab.active { background: var(--fascia); color: #fff; }

#viz-canvas {
    display: block;
    width: 100%;
    height: 380px;
    background: var(--bg);
}

.viz-desc {
    margin-top: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted);
    line-height: 1.6;
}

/* Phase portrait sub-system selector */
.phase-system-row {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    border-bottom: 1px solid var(--joint);
}
.phase-system-btn {
    padding: 7px 14px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-right: 1px solid var(--joint);
    transition: background 0.12s, color 0.12s;
}
.phase-system-btn:hover  { color: var(--ink); }
.phase-system-btn.active { color: var(--red); }

#bif-tooltip {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    color: var(--muted);
    height: 1.4em;
    margin-top: 8px;
}

/* ════════════════════════════════════
   THEOREM DISPLAY
════════════════════════════════════ */

.theorem-name {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    margin-bottom: 6px;
}

.theorem-body {
    margin: 16px 0;
    font-size: 1rem;
    color: var(--ink);
    line-height: 1.9;
}

.theorem-body .katex { font-size: 1em; }

.theorem-credit {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    color: var(--muted);
    letter-spacing: 0.06em;
}

/* ════════════════════════════════════
   MATH CLOCK
════════════════════════════════════ */

#clock-display {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 500;
    color: var(--ink);
    letter-spacing: 0.04em;
    line-height: 1;
    margin: 12px 0 10px;
}

#clock-expr {
    font-size: 0.95rem;
    color: var(--muted);
    min-height: 1.8em;
}

#clock-expr .katex { font-size: 0.95em; }

.clock-panel {
    display: flex;
    flex-direction: column;
}

.clock-binary {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--joint);
}

.clock-binary-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.clock-binary-title,
.clock-binary-meta,
.clock-binary-weight,
.clock-binary-label,
.clock-binary-summary {
    font-family: 'IBM Plex Mono', monospace;
}

.clock-binary-title {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
}

.clock-binary-meta {
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.clock-binary-grid {
    display: grid;
    grid-template-columns: 18px repeat(6, minmax(0, 1fr));
    gap: 6px;
    align-items: center;
}

.clock-binary-corner {
    height: 1px;
}

.clock-binary-weight {
    font-size: 0.62rem;
    color: var(--muted);
    text-align: center;
}

.clock-binary-label {
    font-size: 0.74rem;
    font-weight: 500;
    text-transform: uppercase;
}

.clock-binary-label-hours { color: var(--red); }
.clock-binary-label-minutes { color: var(--blue); }
.clock-binary-label-seconds { color: #9f7a00; }

.clock-bit {
    display: grid;
    place-items: center;
    min-height: 34px;
    border: 1px solid var(--joint);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.78rem;
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.clock-bit.is-on {
    transform: translateY(-1px);
    color: #fff;
}

.clock-bit-hours.is-on {
    background: var(--red);
    border-color: var(--red);
}

.clock-bit-minutes.is-on {
    background: var(--blue);
    border-color: var(--blue);
}

.clock-bit-seconds.is-on {
    background: var(--yellow);
    border-color: #bf9400;
    color: var(--fascia);
}

.clock-binary-summary {
    margin-top: 14px;
    color: var(--ink);
    font-size: 0.8rem;
    letter-spacing: 0.18em;
}

@media (max-width: 640px) {
    .clock-binary-meta { display: none; }
    .clock-binary-grid { gap: 4px; }
    .clock-bit { min-height: 28px; font-size: 0.72rem; }
    .clock-binary-summary { font-size: 0.72rem; letter-spacing: 0.12em; }
}
