/* ==============================================================
   transactology.org
   A systematic inquiry into the nature of exchange.
   ============================================================== */

@property --angle1 {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@property --angle2 {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

:root {
    /* Palette */
    --bg-primary: #1E1B2E;
    --bg-secondary: #2A2438;
    --aurora-a: #3A2D5C;
    --aurora-b: #1B3A3A;
    --aurora-c: #4A2A3A;
    --text-primary: #E8DFD0;
    --text-secondary: #B8A99A;
    --accent: #C4A087;
    --decorative: #7A6B5C;
    --card-surface: #2E2842;

    /* Type */
    --font-display: "Playfair Display", "Playfair", Georgia, serif;
    --font-body: "Commissioner", "IBM Plex Sans", "Inter", system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, monospace;

    /* Layout */
    --column: 720px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.72;
    font-weight: 400;
    overflow-x: hidden;
    position: relative;
}

/* ==============================================================
   Aurora background layers
   ============================================================== */

.aurora-layer {
    position: fixed;
    inset: -20%;
    z-index: -2;
    pointer-events: none;
    mix-blend-mode: screen;
    opacity: 0.55;
    filter: blur(60px);
}

.aurora-layer.layer-1 {
    background: conic-gradient(
        from var(--angle1),
        var(--aurora-a) 0deg,
        transparent 60deg,
        var(--aurora-b) 180deg,
        transparent 240deg,
        var(--aurora-a) 360deg
    );
    animation: spin1 60s linear infinite;
}

.aurora-layer.layer-2 {
    background: conic-gradient(
        from var(--angle2),
        var(--aurora-c) 0deg,
        transparent 80deg,
        var(--aurora-a) 180deg,
        transparent 260deg,
        var(--aurora-c) 360deg
    );
    animation: spin2 90s linear infinite;
    opacity: 0.4;
}

@keyframes spin1 {
    from { --angle1: 0deg; }
    to   { --angle1: 360deg; }
}

@keyframes spin2 {
    from { --angle2: 0deg; }
    to   { --angle2: -360deg; }
}

/* Leather grain overlay */
.leather-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.08;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.91  0 0 0 0 0.87  0 0 0 0 0.82  0 0 0 0.9 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    mix-blend-mode: overlay;
}

/* ==============================================================
   Roman numeral navigation
   ============================================================== */

.roman-nav {
    position: fixed;
    left: 2.2rem;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 10vh 0;
    z-index: 10;
}

.roman-numeral {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.05rem;
    letter-spacing: 0.12em;
    text-decoration: none;
    color: var(--decorative);
    transition: color 600ms ease, transform 600ms ease, letter-spacing 600ms ease;
    padding: 0.2rem 0;
    position: relative;
}

.roman-numeral::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 600ms ease;
    opacity: 0.7;
}

.roman-numeral.active {
    color: var(--accent);
    letter-spacing: 0.22em;
}

.roman-numeral.active::after {
    transform: scaleX(1);
}

/* ==============================================================
   Layout frame
   ============================================================== */

.journal {
    position: relative;
    z-index: 1;
}

.section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8vh 1.5rem;
    position: relative;
}

.section-header {
    max-width: var(--column);
    width: 100%;
    margin: 0 auto 4rem auto;
    text-align: center;
}

.chapter-mark {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--decorative);
    margin-bottom: 1.2rem;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
    letter-spacing: 0.04em;
    color: var(--accent);
    margin-bottom: 1.4rem;
}

.section-lede {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1.02rem;
    line-height: 1.8;
    max-width: 560px;
    margin: 0 auto;
    color: var(--text-secondary);
    font-style: italic;
}

/* ==============================================================
   Section I: The Colophon
   ============================================================== */

.colophon {
    text-align: center;
}

.colophon-inner {
    max-width: var(--column);
    padding: 0 1.5rem;
}

.folio-label {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--decorative);
    margin-bottom: 3rem;
}

.rule {
    border: none;
    height: 1px;
    background: var(--decorative);
    opacity: 0.4;
    margin: 0 auto;
    width: 60%;
    max-width: 420px;
}

.rule-top {
    margin-bottom: 2.5rem;
}

.rule-bottom {
    margin-top: 2.5rem;
    margin-bottom: 2rem;
}

.title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-primary);
    line-height: 1.1;
    margin: 0;
}

.title-dot {
    color: var(--accent);
    font-weight: 400;
    font-style: italic;
    margin: 0 -0.05em;
}

.subtitle {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.04em;
    color: var(--accent);
    margin-bottom: 4rem;
}

.colophon-footnote {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--decorative);
    opacity: 0.8;
}

.scroll-cue {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--decorative);
    animation: cueBreathe 3.2s ease-in-out infinite;
}

.cue-glyph {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--accent);
}

@keyframes cueBreathe {
    0%, 100% { opacity: 0.45; transform: translate(-50%, 0); }
    50%      { opacity: 0.95; transform: translate(-50%, 6px); }
}

/* ==============================================================
   Section II: The Taxonomy
   ============================================================== */

.entries {
    max-width: var(--column);
    width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.entry {
    margin-bottom: 4.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms ease, transform 800ms ease;
}

.entry.in-view {
    opacity: 1;
    transform: translateY(0);
}

.entry-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.entry-code {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--decorative);
    white-space: nowrap;
}

.entry-rule {
    flex: 1;
    border: none;
    height: 1px;
    background: var(--decorative);
    opacity: 0.4;
}

.entry-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.125rem;
    line-height: 1.78;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 1800ms cubic-bezier(0.4, 0, 0.2, 1);
}

.entry.in-view .entry-body {
    clip-path: inset(0 0 0 0);
}

/* ==============================================================
   Section III: The Archive
   ============================================================== */

.archive {
    padding-top: 10vh;
    padding-bottom: 10vh;
}

.catalog-grid {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.8rem;
}

.catalog-card {
    aspect-ratio: 1 / 1;
    background: var(--card-surface);
    position: relative;
    padding: 1.6rem 1.4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: var(--text-primary);
    overflow: hidden;
    border: 1px solid rgba(122, 107, 92, 0.35);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                border-color 400ms ease;
    transition-delay: calc(var(--stagger) * 100ms);
}

.catalog-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.08;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.91  0 0 0 0 0.87  0 0 0 0 0.82  0 0 0 0.9 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    mix-blend-mode: overlay;
}

.catalog-card::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid rgba(196, 160, 135, 0.18);
    pointer-events: none;
}

.catalog-card.in-view {
    opacity: 1;
    transform: translateY(0);
}

.catalog-card:hover {
    border-color: rgba(196, 160, 135, 0.65);
}

.catalog-card:hover .card-glyph svg {
    transform: scale(1.08) rotate(-2deg);
}

.card-code {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--decorative);
    position: relative;
    z-index: 1;
}

.card-glyph {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    position: relative;
    z-index: 1;
}

.card-glyph svg {
    width: 64px;
    height: 64px;
    transition: transform 700ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.card-name {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: 1.35rem;
    letter-spacing: 0.03em;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
    margin-bottom: 0.25rem;
}

.card-sub {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
    font-style: italic;
}

/* ==============================================================
   Section IV: The Marginalia
   ============================================================== */

.marginalia {
    padding-bottom: 14vh;
}

.margin-fragments {
    max-width: var(--column);
    width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.4rem;
}

.fragment {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.72;
    color: var(--text-secondary);
    max-width: 460px;
    transform: translateX(var(--offset, 0));
    opacity: 0;
    transition: opacity 1200ms ease, transform 1200ms ease;
}

.fragment.in-view {
    opacity: 0.92;
    transform: translateX(var(--offset, 0)) translateY(0);
}

.fragment:nth-child(odd) {
    align-self: flex-start;
}

.fragment:nth-child(even) {
    align-self: flex-end;
    text-align: right;
}

.fragment-w-300 { font-weight: 300; font-style: italic; color: var(--text-secondary); }
.fragment-w-400 { font-weight: 400; color: var(--text-primary); }
.fragment-w-500 { font-weight: 500; color: var(--accent); font-style: italic; }

.colophon-end {
    max-width: var(--column);
    width: 100%;
    margin: 8rem auto 0 auto;
    padding: 0 1.5rem;
    text-align: center;
}

.colophon-end .rule {
    margin-bottom: 2rem;
}

.end-mark {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--accent);
    margin-bottom: 1.6rem;
    letter-spacing: 0.4em;
}

.end-glyph {
    color: var(--decorative);
    font-size: 1.3rem;
}

.imprint {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--decorative);
    opacity: 0.8;
}

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

@media (max-width: 900px) {
    .catalog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.2rem;
    }
    .roman-nav {
        left: 1rem;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 17px;
    }
    .catalog-grid {
        grid-template-columns: 1fr;
        max-width: 420px;
    }
    .roman-nav {
        left: 0.7rem;
        padding: 14vh 0;
    }
    .roman-numeral {
        font-size: 0.9rem;
    }
    .section {
        padding: 10vh 1.2rem;
    }
    .section-header {
        margin-bottom: 2.4rem;
    }
    .entry {
        margin-bottom: 3rem;
    }
    .fragment {
        max-width: 100%;
        transform: none;
    }
    .fragment.in-view {
        transform: translateY(0);
    }
    .fragment:nth-child(even) {
        text-align: left;
        align-self: flex-start;
    }
}
