/* ============================================================
   ABEANT — Portal (the cutting mat)
   The Venn IS the page: full-bleed figure drawn straight on
   the sheet, floating glass legend, edge rulers, crosshair.
   ============================================================ */

:root {
    --chrome-bottom: 2.5rem; /* colophon height */
    --ruler: 20px;
    --readout-width: clamp(19rem, 26vw, 22rem);
}

/* ============================================================
   Edge rulers (cutting-mat measurements)
   ============================================================ */

.ruler {
    position: fixed;
    z-index: 90;
    pointer-events: none;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.08em;
    color: var(--ink-3);
}

.ruler--top {
    top: var(--chrome-top);
    left: 0;
    right: 0;
    height: var(--ruler);
    border-bottom: var(--hairline) solid var(--line);
    background-image:
        repeating-linear-gradient(90deg, var(--grid-line-strong) 0, var(--grid-line-strong) 1px, transparent 1px, transparent 150px),
        repeating-linear-gradient(90deg, var(--grid-line) 0, var(--grid-line) 1px, transparent 1px, transparent 30px);
    background-size: 100% 100%, 100% 8px;
    background-position: 0 0, 0 100%;
    background-repeat: no-repeat;
}

.ruler--left {
    top: calc(var(--chrome-top) + var(--ruler));
    bottom: var(--chrome-bottom);
    left: 0;
    width: var(--ruler);
    border-right: var(--hairline) solid var(--line);
    background-image:
        repeating-linear-gradient(180deg, var(--grid-line-strong) 0, var(--grid-line-strong) 1px, transparent 1px, transparent 150px),
        repeating-linear-gradient(180deg, var(--grid-line) 0, var(--grid-line) 1px, transparent 1px, transparent 30px);
    background-size: 100% 100%, 8px 100%;
    background-position: 0 0, 100% 0;
    background-repeat: no-repeat;
}

.ruler span {
    position: absolute;
}

.ruler--top span {
    top: 2px;
}

.ruler--left span {
    left: 2px;
}

/* ============================================================
   Cursor crosshair (alignment guides)
   ============================================================ */

.xhair {
    position: fixed;
    z-index: 5;
    pointer-events: none;
    background: color-mix(in srgb, var(--signal) 45%, transparent);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out);
}

.xhair--v {
    top: 0;
    bottom: 0;
    width: 1px;
    left: 0;
}

.xhair--h {
    left: 0;
    right: 0;
    height: 1px;
    top: 0;
}

body.has-xhair .xhair {
    opacity: 1;
}

@media (hover: none), (pointer: coarse) {
    .xhair {
        display: none;
    }
}

.coords {
    font-variant-numeric: tabular-nums;
}

@media (hover: none), (pointer: coarse) {
    .coords {
        display: none;
    }
}

/* ============================================================
   Stage — the figure owns the viewport
   ============================================================ */

.stage {
    position: relative;
    z-index: 1;
    height: calc(100vh - var(--chrome-top) - var(--chrome-bottom));
    height: calc(100dvh - var(--chrome-top) - var(--chrome-bottom));
    min-height: 0;
    margin-top: var(--chrome-top);
    margin-bottom: var(--chrome-bottom);
    overflow: hidden;
}

.figure {
    position: absolute;
    inset: var(--ruler) 0 0 var(--ruler);
    padding: var(--space-3);
}

/* no reserved column — the legend is transient, the mat owns the view */

/* corner annotations drawn straight on the sheet */
.figure__tag {
    position: fixed;
    z-index: 50;
    pointer-events: none;
}

.figure__tag--nw {
    top: calc(var(--chrome-top) + var(--ruler) + var(--space-3));
    left: calc(var(--ruler) + var(--space-3));
}

.figure__tag--sw {
    bottom: calc(var(--chrome-bottom) + var(--space-3));
    left: calc(var(--ruler) + var(--space-3));
    display: grid;
    gap: 4px;
}

.figure__hint {
    color: var(--ink-3);
}

.venn {
    display: block;
    width: 100%;
    height: 100%;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
    touch-action: pan-y pinch-zoom;
}

.venn.is-panning {
    cursor: grabbing;
}

@media (min-width: 1280px) {
    .venn {
        touch-action: none;
    }
}

/* semantic zoom: minor apps reveal their names as you move in */
.venn__node-label,
.venn__node-status {
    transition: opacity var(--dur-base) var(--ease-out);
}

.venn[data-zoom="far"] .venn__node-label--mini,
.venn[data-zoom="far"] .venn__node-status--mini,
.venn[data-zoom="mid"] .venn__node-label--mini {
    opacity: 0;
}

/* ---- circles: drawn in on load ---- */
.venn__circle {
    fill: none;
    stroke: var(--ink);
    stroke-width: 1.25;
    opacity: 0.82;
    transition: opacity var(--dur-slow) var(--ease-out),
        stroke var(--dur-base) var(--ease-out),
        stroke-dashoffset 1.4s var(--ease-out);
}

.venn--ready .venn__circle {
    stroke-dashoffset: 0 !important;
}

.venn__fill {
    fill: var(--signal);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out);
    pointer-events: none;
}

.venn__fill.is-lit {
    opacity: 0.05;
}

.venn--focused .venn__circle {
    opacity: 0.28;
}

.venn--focused .venn__circle.is-lit {
    opacity: 1;
    stroke: var(--signal);
}

/* ---- pillar labels ---- */
.venn__pillar-group {
    opacity: 0;
    transition: opacity var(--dur-slow) var(--ease-out);
    transition-delay: 1.1s;
}

.venn--ready .venn__pillar-group {
    opacity: 1;
}

.venn__pillar {
    font-family: var(--font-mono);
    font-size: 17px;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    fill: var(--ink);
}

.venn__pillar-sub {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 300;
    fill: var(--ink-2);
}

.venn__pillar-index {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    fill: var(--ink-3);
}

.venn__leader {
    color: var(--ink-3);
}

/* ---- centre registration mark ---- */
.venn__core {
    opacity: 0;
    transition: opacity var(--dur-slow) var(--ease-out);
    transition-delay: 1.25s;
}

.venn--ready .venn__core {
    opacity: 0.85;
}

.venn__core:hover,
.venn__core:focus-visible {
    opacity: 1;
}

/* ---- app nodes ---- */
.venn__node {
    cursor: pointer;
}

.venn__node:focus-visible {
    outline: none;
}

.venn__node:focus-visible .venn__node-plate {
    stroke: var(--signal);
    stroke-width: 2.5;
}

/* inner wrapper so entrance scale doesn't fight the position transform */
.venn__node-inner {
    opacity: 0;
    transform: scale(0.7);
    transition: opacity var(--dur-slow) var(--ease-out),
        transform var(--dur-slow) var(--ease-spring);
    transition-delay: var(--enter-delay, 0.9s);
}

.venn--ready .venn__node-inner {
    opacity: 1;
    transform: scale(1);
}

.venn__node-plate {
    stroke: var(--line);
    stroke-width: 1;
    transition: stroke var(--dur-fast) var(--ease-out);
}

.venn__node-label {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    fill: var(--ink-2);
    text-anchor: middle;
    transition: fill var(--dur-fast) var(--ease-out);
}

.venn__node:hover .venn__node-plate,
.venn__node.is-focused .venn__node-plate {
    stroke: var(--signal);
}

.venn__node:hover .venn__node-label,
.venn__node.is-focused .venn__node-label {
    fill: var(--ink);
}

.venn--focused .venn__node {
    transition: opacity var(--dur-base) var(--ease-out);
}

.venn--focused .venn__node:not(.is-focused) {
    opacity: 0.35;
}

/* discipline focus keeps that pillar's members fully present */
.venn--focused .venn__node.is-member {
    opacity: 1;
}

/* pillar labels + centre mark are legend entries — interactive */
.venn__pillar-group,
.venn__core {
    cursor: pointer;
    outline: none;
}

.venn__pillar-group:hover .venn__pillar,
.venn__pillar-group:focus-visible .venn__pillar {
    fill: var(--signal);
}

.venn__core .venn__core-hit {
    stroke: none;
    fill: transparent;
}

.venn__node--soon image {
    opacity: 0.75;
    filter: grayscale(0.4);
}

.venn__node-status {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    fill: var(--ink-3);
    text-anchor: middle;
}

/* ============================================================
   The readout — floating glass legend
   ============================================================ */

.readout {
    position: fixed;
    z-index: 60;
    top: calc(var(--chrome-top) + var(--ruler) + var(--space-3));
    right: var(--space-4);
    width: var(--readout-width);
    max-height: calc(100dvh - var(--chrome-top) - var(--chrome-bottom) - var(--ruler) - var(--space-5));
    overflow: auto;
    border: var(--hairline) solid var(--line);
    border-radius: var(--radius-m);
    background: color-mix(in srgb, var(--bg-raised) 72%, transparent);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-soft);
}

/* Desktop: the legend is contextual — it only lands on the mat
   while an app, a discipline, or the centre mark is inspected */
@media (min-width: 1280px) {
    .readout {
        top: auto;
        bottom: calc(var(--chrome-bottom) + var(--space-3));
        right: var(--space-3);
        opacity: 0;
        transform: translateY(10px);
        pointer-events: none;
        transition: opacity var(--dur-base) var(--ease-out),
            transform var(--dur-base) var(--ease-out);
    }

    .readout.is-active {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
}

.readout__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: var(--hairline) solid var(--line);
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-3);
}

.readout__body {
    flex: 0 1 auto;
}

.readout__kicker {
    margin: 0 0 var(--space-2);
}

.readout__title {
    font-size: clamp(1.6rem, 2.1vw, 2.2rem);
    margin: 0 0 var(--space-3);
}

.readout__lead {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 1rem;
    line-height: 1.35;
    color: var(--ink-2);
    margin: 0 0 var(--space-3);
}

.readout__note {
    margin: 0;
}

.readout__meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-1) var(--space-3);
    font-size: var(--text-label);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    margin: 0 0 var(--space-3);
}

.readout__meta dt {
    color: var(--ink-3);
}

.readout__meta dd {
    margin: 0;
    color: var(--ink);
}

.readout__meta dd .dot {
    display: inline-block;
    width: 0.5em;
    height: 0.5em;
    border-radius: 50%;
    background: var(--signal);
    margin-right: 0.5em;
    vertical-align: baseline;
}

.readout__meta dd .dot--soon {
    background: var(--ink-3);
}

.readout__foot {
    border-top: var(--hairline) solid var(--line);
    padding-top: var(--space-2);
    margin-top: var(--space-3);
    display: flex;
    justify-content: space-between;
    font-size: var(--text-caption);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--ink-3);
}

/* ============================================================
   Index view — the flat catalogue
   ============================================================ */

.index-view {
    display: none;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--space-5) var(--space-4);
}

.index-view__table {
    width: 100%;
    border-collapse: collapse;
}

.index-view__table th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: var(--text-caption);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    font-weight: 400;
    color: var(--ink-3);
    border-bottom: var(--hairline) solid var(--line-strong);
    padding: var(--space-2) var(--space-3) var(--space-2) 0;
}

.index-view__table td {
    border-bottom: var(--hairline) solid var(--line);
    padding: var(--space-3) var(--space-3) var(--space-3) 0;
    font-size: var(--text-body-s);
    vertical-align: middle;
}

.index-view__row {
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out);
}

.index-view__row:hover {
    background: color-mix(in srgb, var(--bg-recessed) 60%, transparent);
}

.index-view__row:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: -2px;
    background: color-mix(in srgb, var(--bg-recessed) 60%, transparent);
}

.index-view__row:hover .index-view__name {
    color: var(--signal);
}

.index-view__no {
    font-family: var(--font-mono);
    font-size: var(--text-caption);
    letter-spacing: var(--tracking-label);
    color: var(--ink-3);
    width: 3rem;
}

.index-view__icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 22%;
    border: var(--hairline) solid var(--line);
    background: var(--bg-raised);
    padding: 0.3rem;
    display: block;
}

.index-view__name {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: var(--text-title);
    line-height: 1;
    color: var(--ink);
    transition: color var(--dur-fast) var(--ease-out);
}

.index-view__tagline {
    color: var(--ink-2);
    font-family: var(--font-display);
    font-weight: 300;
    font-size: var(--text-body);
}

.index-view__pillars,
.index-view__status {
    font-family: var(--font-mono);
    font-size: var(--text-caption);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--ink-2);
    white-space: nowrap;
}

.index-view__arrow {
    width: 2rem;
    text-align: right;
    color: var(--ink-3);
}

.index-view__row:hover .index-view__arrow {
    color: var(--signal);
}

/* View switching */
body[data-view="index"] .figure,
body[data-view="index"] .figure__tag,
body[data-view="index"] .readout {
    display: none;
}

body[data-view="index"] .index-view {
    display: block;
}

body[data-view="index"] .stage {
    height: auto;
    min-height: calc(100vh - var(--chrome-top) - var(--chrome-bottom));
    min-height: calc(100dvh - var(--chrome-top) - var(--chrome-bottom));
    overflow: visible;
    display: flex;
    align-items: flex-start;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1279px) {

    /* readout becomes a compact instrument panel over the canvas */
    .readout {
        position: fixed;
        top: auto;
        right: var(--space-3);
        bottom: calc(var(--chrome-bottom) + var(--space-3));
        left: calc(var(--ruler) + var(--space-3));
        transform: none;
        width: auto;
        max-height: min(15rem, 36dvh);
        padding: var(--space-3);
        background: color-mix(in srgb, var(--bg-raised) 86%, transparent);
    }
}

@media (max-width: 1023px) {

    .ruler,
    .figure__tag {
        display: none;
    }

    .stage {
        height: calc(100vh - var(--chrome-top) - var(--chrome-bottom));
        height: calc(100dvh - var(--chrome-top) - var(--chrome-bottom));
        margin-top: var(--chrome-top);
    }

    .figure {
        inset: 0;
        padding: var(--space-2);
    }

    .readout {
        left: var(--space-2);
        right: var(--space-2);
        bottom: calc(var(--chrome-bottom) + var(--space-2));
        max-height: min(11rem, 28dvh);
    }
}

@media (max-width: 720px) {

    .readout__head {
        margin-bottom: var(--space-2);
    }

    .readout {
        max-height: min(10.5rem, 26dvh);
    }

    .readout__title {
        font-size: clamp(1.35rem, 6vw, 1.75rem);
        margin-bottom: var(--space-2);
    }

    .readout__lead {
        display: -webkit-box;
        margin-bottom: var(--space-2);
        overflow: hidden;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .readout__meta {
        margin-bottom: var(--space-2);
    }

    .readout__foot {
        display: none;
    }

    .index-view {
        padding: var(--space-4) var(--space-3);
    }

    .index-view__tagline-cell,
    .index-view__pillars-cell {
        display: none;
    }

    .index-view__name {
        font-size: 1.375rem;
    }

    .colophon span:nth-child(2) {
        display: none;
    }

    /* SVG text sizes are viewBox units — scale them up as the
       figure shrinks so labels stay legible on phones */
    .venn__pillar {
        font-size: 34px;
    }

    .venn__pillar-sub {
        font-size: 27px;
    }

    .venn__pillar-index {
        font-size: 21px;
    }

    .venn__node-label {
        font-size: 23px;
    }

    .venn__node-status {
        font-size: 19px;
    }
}

@media (max-width: 389px) {
    .index-view__table td {
        padding: var(--space-2) var(--space-2) var(--space-2) 0;
    }

    .index-view__name {
        font-size: 1.125rem;
    }
}
