/* ============================================================
   miris.tech — Field Engineering Manual of the MiRiS Circle
   Blobitecture inside a strict modular rack.
   Palette: bone paper, shelf grey, charcoal hairline, sage,
   sage light, specimen warmth, chrome label.
   ============================================================ */

:root {
    --bone-paper:      #E8E4DA;
    --shelf-grey:      #D9D5C9;
    --charcoal:        #2A2C28;
    --sage-organ:      #5C6B58;
    --sage-light:      #7A8770;
    --specimen-warm:   #B8896E;
    --chrome-label:    #9C9587;

    --gutter: 18px;
    --hairline: 1.5px;

    --bounce: cubic-bezier(0.34, 1.56, 0.46, 1.0);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: var(--bone-paper);
}

body {
    background: var(--bone-paper);
    color: var(--charcoal);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    letter-spacing: -0.005em;
    font-feature-settings: "tnum" 1;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    position: relative;
}

/* ---------- Background ghost blob ---------- */
.ghost-blob {
    position: fixed;
    bottom: 0;
    right: 12vw;
    width: 56vw;
    max-width: 720px;
    height: 38vh;
    z-index: -1;
    opacity: 0.06;
    pointer-events: none;
}

/* ---------- The Modular Rack ---------- */
.rack {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: var(--gutter);
    display: flex;
    flex-direction: column;
    gap: var(--gutter);
}

.tier {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-auto-rows: minmax(0, 1fr);
    gap: var(--gutter);
}

/* ---------- The Specimen Compartment ---------- */
.cell {
    position: relative;
    aspect-ratio: 5 / 7;
    border: var(--hairline) solid var(--charcoal);
    background: var(--bone-paper);
    padding: 11px 12px 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* slightly uneven hairline feel: a hair of variation per cell */
.cell:nth-child(3n)   { border-width: 1.4px; }
.cell:nth-child(4n+1) { border-width: 1.6px; }

.cell-chrome {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    flex: 0 0 auto;
}

.serial,
.cat {
    font-family: 'Bebas Neue', 'Inter', sans-serif;
    font-size: 9px;
    letter-spacing: 0.2em;
    line-height: 1.0;
    color: var(--chrome-label);
    text-transform: uppercase;
    text-rendering: geometricPrecision;
    white-space: nowrap;
}

.cat {
    text-align: right;
}

.chrome-rule {
    width: 60%;
    height: var(--hairline);
    background: var(--charcoal);
    margin: 7px 0 8px;
    flex: 0 0 auto;
}

/* ---------- Cell body copy (micro / masthead small cells) ---------- */
.cell-body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 12.5px;
    line-height: 1.4;
    letter-spacing: -0.005em;
    color: var(--charcoal);
    position: relative;
    z-index: 2;
    margin-top: auto;
    padding-bottom: 2px;
    /* text settles into the curvature of the blob: wrap up against the right edge */
    max-width: 86%;
}

.mono-stamp {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.4;
    letter-spacing: 0;
    color: var(--chrome-label);
    position: relative;
    z-index: 2;
    margin-top: 3px;
}

/* ---------- The blob stage ---------- */
.blob-stage {
    position: absolute;
    /* weighted to the lower-right corner */
    right: -2%;
    bottom: -2%;
    width: 78%;
    height: 70%;
    z-index: 1;
    pointer-events: none;
}

.blob-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.blob-path {
    fill: var(--shelf-grey);
    stroke: var(--charcoal);
    stroke-width: var(--hairline);
    transition: fill 240ms ease;
    transform-box: fill-box;
    transform-origin: 50% 78%;
}

/* bounce-enter: start state */
.cell:not(.blob-entered) .blob-path {
    opacity: 0;
    transform: scale(0.96);
}
.cell.blob-entered .blob-path {
    animation: blobBounce 480ms var(--bounce) forwards;
}

@keyframes blobBounce {
    0%   { opacity: 0; transform: scale(0.96) scaleY(1.0) scaleX(1.0); }
    18%  { opacity: 1; transform: scale(1.04) scaleY(0.94) scaleX(1.06); }
    100% { opacity: 1; transform: scale(1.0) scaleY(1.0) scaleX(1.0); }
}

/* hover: shelf-grey -> sage; leaf rotates about its stem */
.cell:hover {
    pointer-events: auto;
}
.cell:hover .blob-stage {
    pointer-events: auto;
}
.cell:hover .blob-path {
    fill: var(--sage-organ);
}

/* ---------- The leaf-organic motif ---------- */
.leaf {
    transform-box: fill-box;
    transform-origin: bottom center;
    transition: transform 240ms ease;
}
.cell:not(.blob-entered) .leaf {
    opacity: 0;
}
.cell.blob-entered .leaf {
    animation: leafBounce 420ms var(--bounce) 90ms forwards;
}
.cell:hover .leaf {
    transform: rotate(8deg);
}

@keyframes leafBounce {
    0%   { opacity: 0; transform: scale(0.92) scaleY(0.97); }
    20%  { opacity: 1; transform: scale(1.03) scaleY(0.97); }
    100% { opacity: 1; transform: scale(1.0) scaleY(1.0); }
}

.leaf-blade {
    fill: var(--sage-organ);
}
.leaf-vein {
    stroke: var(--sage-light);
    stroke-width: 1;
    fill: none;
    vector-effect: non-scaling-stroke;
}

/* ---------- The active-anchor warm bracket ---------- */
.bracket-path {
    fill: none;
    stroke: var(--specimen-warm);
    stroke-width: var(--hairline);
    opacity: 0;
    transition: opacity 200ms ease;
}
.cell-anchor.bracket-active .bracket-path {
    opacity: 1;
    animation: bracketDraw 360ms ease forwards;
}

@keyframes bracketDraw {
    from { stroke-dashoffset: var(--perim, 600); }
    to   { stroke-dashoffset: 0; }
}

/* ---------- Anchor cells ---------- */
.cell-anchor {
    grid-column: span 2;
    grid-row: span 2;
    padding: 14px 16px 14px;
}

.anchor-head {
    font-family: 'Bebas Neue', 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(2.6rem, 6vw, 5.5rem);
    line-height: 0.86;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    color: var(--charcoal);
    text-rendering: geometricPrecision;
    text-shadow: 0 0 0 var(--charcoal);
    position: relative;
    z-index: 2;
    margin-bottom: 10px;
}

.mono-lines {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    line-height: 1.5;
    letter-spacing: 0;
    color: var(--charcoal);
    position: relative;
    z-index: 2;
    max-width: 30ch;
}

.domain-glyph {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 14px;
    height: 14px;
    z-index: 3;
    pointer-events: none;
}

/* anchor blobs are bigger / fully visible inside the cell */
.cell-anchor .blob-stage {
    right: -4%;
    bottom: -4%;
    width: 64%;
    height: 64%;
}

.anchor-masthead .anchor-head,
.anchor-colophon .anchor-head {
    font-size: clamp(2.4rem, 5vw, 4.6rem);
}

/* ---------- Cross-reference glyph in the gutter ---------- */
.xref-mark {
    position: absolute;
    width: 8px;
    height: 8px;
    z-index: 4;
    pointer-events: none;
}
.xref-mark circle {
    fill: none;
    stroke: var(--charcoal);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

/* ---------- Responsive: shrink columns, never collapse cells ---------- */
@media (max-width: 1100px) {
    .tier { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 820px) {
    .tier { grid-template-columns: repeat(4, 1fr); }
    .cell-anchor { padding: 12px; }
}
@media (max-width: 600px) {
    .tier { grid-template-columns: repeat(2, 1fr); }
    .anchor-head { font-size: clamp(2.2rem, 9vw, 3.4rem); }
    .anchor-masthead .anchor-head,
    .anchor-colophon .anchor-head { font-size: clamp(2rem, 8vw, 3rem); }
}
@media (max-width: 480px) {
    .tier { grid-template-columns: 1fr; }
    .cell-anchor { grid-column: span 1; grid-row: span 2; }
}
