/* ==========================================================================
   Simplex Website Styles

   Design: Minimal, center-aligned, monochrome
   Inspired by: Mechanize (layout), Physical Intelligence (works timeline)
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables - Easy to customize
   -------------------------------------------------------------------------- */
:root {
    /* Colors */
    --color-bg: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #666666;
    --color-border: #e0e0e0;
    --color-border-dark: #1a1a1a;

    /* Typography - swap these to change fonts site-wide */
    --font-heading: "Cardo", Georgia, serif;
    --font-body: Georgia, "Times New Roman", serif;

    /* Spacing */
    --max-width: 600px;
    --section-spacing: 4rem;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.65;
    color: var(--color-text);
    background: var(--color-bg);
    margin: 0;
    padding: 0 1.5rem;
    -webkit-font-smoothing: antialiased;
}

main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 0 4rem;
    position: relative;
    z-index: 1;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1, h2, h3 {
    margin: 0;
    font-weight: 400;
}

h2 {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

p {
    margin: 0 0 1rem;
}

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

a {
    color: inherit;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: text-decoration-thickness 0.1s ease;
}

a:hover {
    text-decoration-thickness: 2px;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 3rem;
    margin-bottom: 2rem;
    border-bottom: 1px dotted var(--color-text);
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    position: relative;
    padding-left: 2.6em;
}

.logo-canvas {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 2.3em;
    width: 2.3em;
    cursor: pointer;
    pointer-events: auto;
}

.logo-link {
    text-decoration: none;
    color: inherit;
}

nav {
    display: flex;
    gap: 1.5rem;
}

nav a {
    font-size: 14px;
    text-decoration: none;
}

nav a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */
section {
    margin-bottom: var(--section-spacing);
}

#intro {
    margin-bottom: 2.5rem;
    position: relative;
}

/* --------------------------------------------------------------------------
   Works / Research Timeline
   -------------------------------------------------------------------------- */
.works-timeline {
    margin-left: 0;
    font-family: var(--font-body);
}

.year-header {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dotted var(--color-text);
}

.year-header:first-child {
    margin-top: 0;
}

.work {
    display: block;
    padding: 1rem 1rem 1rem 1.25rem;
    margin-bottom: 0.75rem;
    border-left: 2px solid var(--color-border);
    text-decoration: none;
    transition: all 0.15s ease;
}

.work:hover {
    border-left-color: var(--color-text-muted);
}

.work:hover .work-title {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.work-date {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--color-text-muted);
}

.work-title {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.35rem;
}

.work-authors {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.5;
}

.work-description {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--color-text);
    margin: 0.75rem 0 0;
    line-height: 1.55;
}

.work-badge {
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border: 1px solid currentColor;
    color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Layout Variant A: Inline Right-Aligned
   -------------------------------------------------------------------------- */
.works--variant-a .work {
    display: block;
    padding: 0.875rem 1rem;
    margin-bottom: 0.625rem;
    border: 1px solid var(--color-border);
    text-decoration: none;
    transition: all 0.15s ease;
}

.works--variant-a .work:hover {
    border-color: var(--color-text-muted);
}

/* 3-Tier: MAJOR - background tint, black border, shadow */
.works--variant-a .work--major {
    background: #faf9f7;
    border: 1px solid var(--color-border-dark);
    box-shadow: 3px 3px 0 var(--color-border-dark);
    padding: 1.125rem 1.25rem;
}

.works--variant-a .work--major:hover {
    box-shadow: 4px 4px 0 var(--color-border-dark);
}

.works--variant-a .work--major .work-title {
    font-size: 15px;
    font-weight: 600;
}

.works--variant-a .work--major .work-description {
    font-size: 13px;
    color: var(--color-text);
    margin: 0.6rem 0 0;
    line-height: 1.5;
}

/* 3-Tier: STANDARD - white background, medium border, subtle shadow */
.works--variant-a .work--standard {
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 1px 1px 0 #ddd;
    padding: 1rem 1.125rem;
}

.works--variant-a .work--standard:hover {
    border-color: #999;
    box-shadow: 2px 2px 0 #ccc;
}

.works--variant-a .work--standard .work-description {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 0.4rem 0 0;
    line-height: 1.45;
}

/* 3-Tier: MINOR - cool gray tint, light border, no shadow, reduced weight */
.works--variant-a .work--minor {
    background: #f6f6f8;
    border: 1px solid #e8e8ec;
    box-shadow: none;
    padding: 0.75rem 1rem;
}

.works--variant-a .work--minor:hover {
    border-color: #d0d0d8;
    background: #f2f2f5;
}

.works--variant-a .work--minor .work-title {
    font-size: 13px;
    font-weight: 400;
    color: #555;
}

.works--variant-a .work--minor .work-authors {
    font-size: 11px;
}

.works--variant-a .work--minor .work-badge {
    font-size: 9px;
    opacity: 0.8;
}

.works--variant-a .work--minor .work-date {
    font-size: 11px;
}

.works--variant-a .work-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.works--variant-a .work-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
    flex: 1;
}

.works--variant-a .work-authors {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 0.25rem 0 0;
    flex: 1;
}

.works--variant-a .work-badge {
    font-size: 10px;
    padding: 1px 5px;
    flex-shrink: 0;
}

.works--variant-a .work-date {
    font-size: 12px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Research Style: Rounded (rounded corners on cards)
   -------------------------------------------------------------------------- */
.works-timeline.works--rounded .work--major,
.works-timeline.works--rounded .work--standard,
.works-timeline.works--rounded .work--minor {
    border-radius: 8px;
    border: 1px solid var(--color-border);
    border-left: 1px solid var(--color-border);
    box-shadow: none;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.works-timeline.works--rounded .work--major {
    border-color: var(--color-border-dark);
    box-shadow: 3px 3px 0 var(--color-border-dark);
}

.works-timeline.works--rounded .work--minor {
    border-color: var(--color-border);
    background: transparent;
}

.works-timeline.works--rounded .work--major:hover {
    box-shadow: 5px 5px 0 var(--color-border-dark);
}

.works-timeline.works--rounded .work--standard:hover {
    border-color: var(--color-text-muted);
}

.works-timeline.works--rounded .work--minor:hover {
    border-color: var(--color-text-muted);
}

.works-timeline.works--rounded .work-badge {
    border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Color Overlay: Sand (warm tan)
   -------------------------------------------------------------------------- */
.works-timeline.works--color-sand .work--major { background-color: #ddd2bc; }
.works-timeline.works--color-sand .work--standard { background-color: #e8e0cf; }
.works-timeline.works--color-sand .work--minor { background-color: #f0ebe0; }
.works-timeline.works--color-sand .work--major:hover { background-color: #d2c5a9; }
.works-timeline.works--color-sand .work--standard:hover { background-color: #e0d6c2; }
.works-timeline.works--color-sand .work--minor:hover { background-color: #eae4d5; }

/* --------------------------------------------------------------------------
   Contact Form
   -------------------------------------------------------------------------- */
.contact-form {
    margin-top: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-field {
    flex: 1;
}

.form-field {
    display: block;
    margin-bottom: 0.75rem;
}

.form-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
}

.contact-form input,
.contact-form textarea {
    width: 100%;
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-text);
    background: #fff;
    border: 1px solid var(--color-border);
    padding: 0.5rem 0.625rem;
    transition: border-color 0.15s ease;
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: var(--color-text-muted);
}

.contact-form textarea {
    resize: vertical;
    min-height: 80px;
}

.form-submit {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 24px;
    border-radius: 8px;
    border: 1px solid var(--color-border-dark);
    background: #f8f7f5;
    color: var(--color-border-dark);
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--color-border-dark);
    transition: box-shadow 0.1s ease, transform 0.1s ease;
}

.form-submit:hover {
    background: #f0efed;
    box-shadow: 3px 3px 0 #333;
}

.form-submit:active {
    box-shadow: 1px 1px 0 var(--color-border-dark);
    transform: translate(1px, 1px);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
footer {
    margin-top: var(--section-spacing);
    padding-top: 2rem;
    border-top: 1px dotted var(--color-text);
}

footer p {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   About Detail Toggle
   -------------------------------------------------------------------------- */
.about-detail-toggle {
    text-align: center;
    margin: 1rem 0;
}

.about-expand-btn {
    background: none;
    border: 1px solid var(--color-border);
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: #999;
    padding: 0.3rem 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.about-expand-btn:hover {
    color: var(--color-text);
    border-color: var(--color-border-dark);
}

.about-detail {
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    max-height: 0;
    opacity: 0;
}

.about-detail.about-detail--open {
    max-height: 2000px;
    opacity: 1;
}

/* --------------------------------------------------------------------------
   Demo Widget
   -------------------------------------------------------------------------- */
.demo-intro {
    margin-bottom: 1.5rem;
}

.demo-box {
    padding: 1.25rem;
}

.param-controls {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 12px;
}

.param {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-body);
    font-size: 10px;
    cursor: pointer;
}

.param-label {
    color: #666;
    min-width: 1ch;
}

.param-value {
    min-width: 4ch;
    text-align: right;
    color: #666;
}

/* Ableton-style fader sliders */
.param input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 50px;
    height: 16px;
    background: transparent;
    cursor: pointer;
}

.param input[type="range"]::-webkit-slider-runnable-track {
    height: 2px;
    background: #ccc;
    border-radius: 0;
}

.param input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 4px;
    height: 14px;
    background: #1a1a1a;
    border: none;
    border-radius: 0;
    margin-top: -6px;
    cursor: grab;
}

.param input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
}

.param input[type="range"]::-moz-range-track {
    height: 2px;
    background: #ccc;
    border-radius: 0;
    border: none;
}

.param input[type="range"]::-moz-range-thumb {
    width: 4px;
    height: 14px;
    background: #1a1a1a;
    border: none;
    border-radius: 0;
    cursor: grab;
}

.param input[type="range"]::-moz-range-thumb:active {
    cursor: grabbing;
}

.demo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}

.demo-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel-header {
    font-family: var(--font-body);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    color: #aaa;
}

.data-content {
    border: 1px solid var(--color-border);
    padding: 8px;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    overflow-x: visible;
    overflow-y: hidden;
}

.data-viz-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.hmm-diagram, .belief-simplex {
    flex: 1;
}

.hmm-diagram svg { display: block; width: 100%; height: auto; }

.belief-simplex canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1;
}

.data-samples {
    font-size: 0;
    line-height: 1;
    flex: 1;
    text-align: center;
    min-height: 0;
}

.data-samples .seq-line {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-bottom: 2px;
}

.token-chip {
    width: 14px;
    height: 14px;
    border-radius: 0;
    line-height: 14px;
    text-align: center;
    font-size: 8px;
    font-weight: 700;
    font-family: var(--font-body);
    color: #1a1a1a;
    flex-shrink: 0;
}

.token-chip--a { background: #f4d03f; }
.token-chip--b { background: #e67e22; }
.token-chip--c { background: #9b59b6; }
.token-chip--empty {
    background: transparent;
    border: 1px solid rgba(0,0,0,0.1);
}

.panel-middle canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 0;
    border: 1px solid var(--color-border);
    margin-top: auto;
}

.scatter-wrap {
    position: relative;
    cursor: grab;
    margin-top: auto;
}

.scatter-wrap:active { cursor: grabbing; }

.scatter-wrap canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 0;
    border: 1px solid var(--color-border);
}

.demo-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
}

#btn-train {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 24px;
    border-radius: 8px;
    border: 1px solid var(--color-border-dark);
    background: #f8f7f5;
    color: var(--color-border-dark);
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--color-border-dark);
    transition: box-shadow 0.1s ease, transform 0.1s ease;
}

#btn-train:hover {
    background: #f0efed;
    border-color: #333;
    box-shadow: 3px 3px 0 #333;
}

#btn-train:active {
    box-shadow: 1px 1px 0 var(--color-border-dark);
    transform: translate(1px, 1px);
}

#btn-train:disabled {
    opacity: 0.35;
    cursor: default;
    box-shadow: 2px 2px 0 var(--color-border-dark);
    transform: none;
}

.demo-caption {
    font-size: 11px;
    color: #999;
    text-align: center;
    margin-top: 8px;
    line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 500px) {
    body {
        font-size: 14px;
        padding: 0 1rem;
    }

    main {
        padding: 2rem 0 3rem;
    }

    header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    nav {
        gap: 1rem;
    }

    .work {
        padding: 0.875rem 0.875rem 0.875rem 1rem;
    }

    /* Variant A mobile */
    .works--variant-a .work-row {
        flex-wrap: wrap;
    }
    .works--variant-a .work-badge,
    .works--variant-a .work-date {
        order: -1;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

@media (max-width: 620px) {
    .demo-box {
        display: flex;
        flex-direction: column;
    }

    .demo-box .param-controls { order: 1; }
    .demo-box .demo-controls  { order: 2; margin-bottom: 12px; }
    .demo-box .demo-caption   { order: 3; margin-bottom: 16px; }
    .demo-box .demo-grid      { order: 4; }

    .demo-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .scatter-wrap canvas {
        max-height: 280px;
        object-fit: contain;
    }
}
