/* ==========================================================================
   Lifeform - page-level components
   ========================================================================== */

/* --------------------------------------------------------------- hero */
.hero {
    position: relative;
    min-height: min(88vh, 860px);
    display: flex;
    align-items: center;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
}

.hero-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: .78;
}
:root[data-theme="light"] .hero-canvas { opacity: .62; }

/* Keeps the automaton scenery rather than competition: the plate under the
   headline is nearly opaque and fades out to the right. */
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(74% 62% at 20% 46%, var(--void) 0%, color-mix(in srgb, var(--void) 82%, transparent) 45%, transparent 78%),
        linear-gradient(100deg, var(--void) 4%, color-mix(in srgb, var(--void) 55%, transparent) 40%, transparent 66%),
        linear-gradient(to top, var(--void) 2%, transparent 42%);
}

/* On a phone the headline sits over the whole width of the automaton, so the
   diagonal plate that works on a wide screen becomes a flat vertical one. The
   scrim stays light and the cells are dimmed instead - blanketing the canvas
   made the text legible but left the hero looking empty. */
@media (max-width: 820px) {
    .hero-canvas { opacity: .5; }
    :root[data-theme="light"] .hero-canvas { opacity: .38; }
    .hero::after {
        background:
            linear-gradient(180deg, var(--void) 0%,
                            color-mix(in srgb, var(--void) 68%, transparent) 20%,
                            color-mix(in srgb, var(--void) 60%, transparent) 68%,
                            var(--void) 100%);
    }
}

.hero-inner { position: relative; z-index: 2; padding-block: clamp(4rem, 10vw, 7rem); }
.hero-content { max-width: 46rem; }

.hero h1 {
    font-size: clamp(2.6rem, 7.2vw, 5.1rem);
    line-height: 1.02;
    letter-spacing: -0.042em;
    margin-bottom: .5rem;
}
.hero h1 em {
    font-style: normal;
    color: var(--accent);
    text-shadow: 0 0 40px var(--accent-glow);
}

.hero-sub {
    font-size: clamp(1.05rem, 2vw, 1.32rem);
    line-height: 1.55;
    color: var(--ink-2);
    max-width: 44ch;
    margin: 1.2rem 0 2rem;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }

.hero-rule {
    display: inline-flex;
    align-items: center;
    gap: .8rem;
    margin-top: 2.6rem;
    padding: .55rem .85rem .55rem .6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--panel) 75%, transparent);
    backdrop-filter: blur(8px);
    font-family: var(--font-mono);
    font-size: .78rem;
    color: var(--ink-3);
}
.hero-rule b { color: var(--accent); font-weight: 500; }
@media (max-width: 620px) {
    /* the full sentence wraps to three lines and looks broken on a phone */
    .hero-rule .rule-tail { display: none; }
    .hero-rule { margin-top: 2rem; }
}
.hero-rule .dot {
    width: 7px; height: 7px;
    border-radius: 1px;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    animation: pulse 2.4s var(--ease) infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .28; } }

.scroll-cue {
    position: absolute;
    left: 50%;
    bottom: 1.6rem;
    z-index: 3;
    translate: -50% 0;
    color: var(--ink-4);
    font-family: var(--font-mono);
    font-size: .68rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}
.scroll-cue span { width: 1px; height: 26px; background: linear-gradient(var(--line-strong), transparent); }

/* --------------------------------------------------------------- ticker */
.ticker {
    border-block: 1px solid var(--line-soft);
    background: color-mix(in srgb, var(--panel) 45%, transparent);
    overflow: hidden;
}
.ticker-inner {
    display: flex;
    gap: 3rem;
    padding-block: .85rem;
    font-family: var(--font-mono);
    font-size: .78rem;
    letter-spacing: .06em;
    color: var(--ink-3);
    white-space: nowrap;
}
.ticker-inner b { color: var(--ink); font-weight: 500; }
.ticker-item { display: inline-flex; align-items: center; gap: .55rem; }
.ticker-item::before {
    content: "";
    width: 5px; height: 5px;
    background: var(--accent);
    border-radius: 1px;
    opacity: .8;
}

/* --------------------------------------------------------------- feature split */
.split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
}
.split--reverse > *:first-child { order: 2; }

.frame {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--canvas-bg);
    overflow: hidden;
    box-shadow: var(--shadow-3);
}
.frame-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .9rem;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    font-family: var(--font-mono);
    font-size: .7rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-4);
}
.frame-bar .dots { display: flex; gap: .3rem; }
.frame-bar .dots i {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--line-strong);
}
.frame canvas { width: 100%; display: block; aspect-ratio: 16 / 10; }

.feature-list { list-style: none; margin: 1.6rem 0 0; padding: 0; }
.feature-list li {
    display: flex;
    gap: .9rem;
    padding: .85rem 0;
    border-top: 1px solid var(--line-soft);
    color: var(--ink-2);
    font-size: .95rem;
}
.feature-list li:last-child { border-bottom: 1px solid var(--line-soft); }
.feature-list b { display: block; color: var(--ink); font-weight: 600; margin-bottom: .12rem; }
.feature-list .mark { flex: none; color: var(--accent); padding-top: .18rem; }
.feature-list .mark svg { width: 17px; height: 17px; }

/* --------------------------------------------------------------- rule demo */
.rule-demo {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.6rem;
    align-items: center;
    padding: 1.4rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    margin: 2.2rem 0;
}
.rule-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 7), 1fr);
    gap: 3px;
    max-width: 320px;
    margin-inline: auto;
    width: 100%;
}
.rule-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    border: 1px solid var(--line-soft);
    background: var(--surface);
    cursor: pointer;
    position: relative;
    transition: background .12s var(--ease), border-color .12s var(--ease);
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: .6rem;
    color: transparent;
}
.rule-cell:hover { border-color: var(--accent); }
.rule-cell.is-alive { background: var(--cell-2); border-color: transparent; }
.rule-cell.show-count { color: var(--ink-4); }
.rule-cell.is-alive.show-count { color: var(--accent-ink); }
.rule-cell.is-focus { outline: 2px solid var(--amber); outline-offset: 1px; z-index: 1; }
.rule-cell.will-live::after,
.rule-cell.will-die::after {
    content: "";
    position: absolute;
    inset: 26%;
    border-radius: 50%;
}
.rule-cell.will-live::after { background: var(--lime); }
.rule-cell.will-die::after { background: var(--rose); }

.rule-readout { font-size: .92rem; color: var(--ink-2); }
.rule-readout dl { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 1rem 0 0; }
.rule-readout dt { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); }
.rule-readout dd { margin: 0; color: var(--ink); font-weight: 550; }

/* --------------------------------------------------------------- timeline */
.timeline { position: relative; margin: 2.5rem 0 0; padding-left: 2.2rem; }
.timeline::before {
    content: "";
    position: absolute;
    left: 6px; top: .5rem; bottom: .5rem;
    width: 1px;
    background: linear-gradient(var(--line-strong), var(--line-soft));
}
.tl-item { position: relative; padding-bottom: 2.2rem; }
.tl-item::before {
    content: "";
    position: absolute;
    left: -2.2rem; top: .45rem;
    width: 13px; height: 13px;
    border-radius: 3px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    transition: all .2s var(--ease);
}
.tl-item:hover::before { background: var(--accent); border-color: transparent; box-shadow: 0 0 0 4px var(--accent-glow); }
.tl-year {
    font-family: var(--font-mono);
    font-size: .76rem;
    letter-spacing: .1em;
    color: var(--accent);
    margin-bottom: .25rem;
}
.tl-item h3 { font-size: 1.08rem; margin-bottom: .35rem; }
.tl-item p { color: var(--ink-2); font-size: .95rem; margin: 0; max-width: 62ch; }

/* --------------------------------------------------------------- accordion */
.accordion { border-top: 1px solid var(--line); }
.accordion details {
    border-bottom: 1px solid var(--line);
}
.accordion summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem .2rem;
    cursor: pointer;
    list-style: none;
    font-family: var(--font-display);
    font-size: 1.04rem;
    font-weight: 550;
    letter-spacing: -0.018em;
    color: var(--ink);
    transition: color .16s var(--ease);
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:hover { color: var(--accent); }
.accordion summary::after {
    content: "";
    flex: none;
    width: 11px; height: 11px;
    border-right: 1.5px solid var(--ink-3);
    border-bottom: 1.5px solid var(--ink-3);
    rotate: 45deg;
    translate: 0 -3px;
    transition: rotate .22s var(--ease);
}
.accordion details[open] summary::after { rotate: -135deg; translate: 0 2px; }
.accordion .acc-body { padding: 0 .2rem 1.4rem; color: var(--ink-2); font-size: .98rem; max-width: 74ch; }
.accordion .acc-body p:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------- glossary */
.glossary { display: grid; gap: 0; }
.gl-item {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 1.5rem;
    padding: 1.05rem 0;
    border-bottom: 1px solid var(--line-soft);
}
.gl-item dt {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.015em;
    margin: 0;
}
.gl-item dd { margin: 0; color: var(--ink-2); font-size: .95rem; }
.gl-letter {
    font-family: var(--font-mono);
    font-size: .72rem;
    letter-spacing: .16em;
    color: var(--accent);
    padding-top: 2rem;
    margin-bottom: .3rem;
    border-top: 1px solid var(--line);
}
.gl-letter:first-child { padding-top: 0; border-top: 0; }

@media (max-width: 620px) {
    .gl-item { grid-template-columns: 1fr; gap: .3rem; }
}

/* --------------------------------------------------------------- gallery */
.gallery-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1.4rem;
    margin-bottom: 1.8rem;
    border-bottom: 1px solid var(--line-soft);
}
.gallery-search { display: flex; gap: .5rem; align-items: center; min-width: 260px; flex-wrap: wrap; }
@media (max-width: 560px) {
    /* the search box, the sort and the button will not sit on one 360px row */
    .gallery-search { width: 100%; min-width: 0; }
    .gallery-search input[type="search"] { flex: 1 1 100%; }
    .gallery-search select { flex: 1 1 auto; }
}

.pattern-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: start;
}
.pattern-stage {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--canvas-bg);
    overflow: hidden;
    position: relative;
}
.pattern-stage canvas { width: 100%; aspect-ratio: 4 / 3; }
.pattern-stage-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .55rem .8rem;
    border-top: 1px solid var(--line);
    background: var(--panel);
    font-family: var(--font-mono);
    font-size: .72rem;
    color: var(--ink-3);
}
.pattern-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .55rem 1.2rem;
    margin: 1.4rem 0;
    padding: 1.1rem 0;
    border-block: 1px solid var(--line-soft);
    font-size: .9rem;
}
.pattern-facts dt {
    font-family: var(--font-mono);
    font-size: .7rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-4);
    padding-top: .16rem;
}
.pattern-facts dd { margin: 0; color: var(--ink); }

@media (max-width: 860px) {
    .pattern-hero { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------- rules table */
.rules-table td code { white-space: nowrap; }
.rule-swatch {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 2px;
    margin-right: .5rem;
    vertical-align: -1px;
}

/* --------------------------------------------------------------- notice */
.notice {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .8rem 1rem;
    border: 1px solid var(--line);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--panel);
    font-size: .9rem;
    color: var(--ink-2);
    margin-bottom: 1.5rem;
}
.notice--danger { border-left-color: var(--rose); }
.notice svg { width: 18px; height: 18px; flex: none; color: var(--accent); }

/* --------------------------------------------------------------- empty state */
.empty {
    text-align: center;
    padding: clamp(3rem, 8vw, 5rem) 1rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--ink-3);
}
.empty h3 { color: var(--ink-2); }

/* --------------------------------------------------------------- error page */
.error-page {
    min-height: 72vh;
    display: grid;
    place-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.error-code {
    font-family: var(--font-mono);
    font-size: clamp(4rem, 16vw, 9rem);
    font-weight: 300;
    letter-spacing: -0.05em;
    color: var(--ink);
    line-height: 1;
    opacity: .2;
    margin-bottom: -.35em;
}
/* The automaton is scenery here, so it is masked out of the middle where the
   message sits and faded at the edges so it has no visible rectangle. */
.error-page canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: .45;
    z-index: 0;
    /* One ring-shaped mask: hidden under the message, visible through the middle
       band, and faded out again before the canvas edge so there is no rectangle.
       A single gradient avoids relying on mask-composite, which is patchy. */
    -webkit-mask-image: radial-gradient(96% 88% at 50% 46%, transparent 6%, rgba(0, 0, 0, .5) 38%, #000 62%, transparent 99%);
    mask-image: radial-gradient(96% 88% at 50% 46%, transparent 6%, rgba(0, 0, 0, .5) 38%, #000 62%, transparent 99%);
}
.error-page > div { position: relative; z-index: 1; }
.error-page .btn-row { justify-content: center; }
