/* licence.broker - 1970s Cinematic Bureaucratic Design */

:root {
    --primary-dark: #1C1914;
    --canvas-base: #2A2218;
    --gold-display: #D4A84B;
    --warm-accent: #C4956A;
    --body-text: #B8A88E;
    --muted-ground: #7A7060;
    --cool-accent: #3A4A5E;
    --seal-red: #8B3A2A;
    --scene3-cool: #1E2430;
    --scene5-amber: #2D2012;
    --muted-warm: #8A7D6A;

    --canvas-bg: var(--canvas-base);
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
}

body {
    font-family: 'Libre Baskerville', 'Inter', serif;
    font-weight: 400;
    color: var(--body-text);
    background-color: var(--primary-dark);
    overflow-x: hidden;
    position: relative;
}

/* Film Grain Overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" result="noise"/></filter><rect width="256" height="256" fill="%23000" filter="url(%23noise)" opacity="0.04"/></svg>');
    background-size: 256px 256px;
    pointer-events: none;
    opacity: 0;
    animation: grain-fade-in 1.2s ease-out 0.6s forwards;
    mix-blend-mode: overlay;
    will-change: background-position;
    animation: grain-flicker 0.1s steps(4) infinite 1.2s;
}

@keyframes grain-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 0.04;
    }
}

@keyframes grain-flicker {
    0% {
        background-position: 0 0;
    }
    25% {
        background-position: 1px 1px;
    }
    50% {
        background-position: 2px 0;
    }
    75% {
        background-position: 0 2px;
    }
    100% {
        background-position: 1px 1px;
    }
}

/* SIDEBAR */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 30%;
    height: 100vh;
    background-color: var(--primary-dark);
    border-right: 1px solid rgba(196, 149, 106, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    z-index: 100;
    opacity: 0;
    animation: sidebar-fade-in 0.6s ease-out forwards;
}

@keyframes sidebar-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 0.6;
    }
}

.sidebar-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-family: 'Jost', sans-serif;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.3em;
    color: var(--muted-warm);
    position: absolute;
    top: 50%;
    transform: translateY(-50%) rotate(180deg);
}

.document-tray {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 80px;
    width: 100%;
    padding: 0 10px;
}

.document {
    width: 100%;
    aspect-ratio: 1 / 1.414;
    background: linear-gradient(135deg, rgba(212, 168, 75, 0.1) 0%, rgba(196, 149, 106, 0.05) 100%);
    border-top: 2px solid var(--warm-accent);
    border-radius: 1px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 1px rgba(0, 0, 0, 0.15);
    position: relative;
    opacity: 0;
    animation: doc-fade-in 0.6s ease-out forwards;
    animation-delay: calc(0.15s * var(--index));

    &::before {
        content: '';
        position: absolute;
        left: 8px;
        right: 8px;
        top: 30%;
        height: 2px;
        background: linear-gradient(90deg, var(--muted-ground) 0%, transparent 100%);
        opacity: 0.3;
    }

    &::after {
        content: '';
        position: absolute;
        left: 8px;
        right: 8px;
        top: 50%;
        height: 1px;
        background: linear-gradient(90deg, var(--muted-ground) 0%, transparent 100%);
        opacity: 0.2;
    }
}

@keyframes doc-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* MAIN CANVAS */
.canvas {
    margin-left: 30%;
    background-color: var(--canvas-bg);
    transition: background-color 0.8s ease;
}

.scene {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    position: relative;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* SCENE 1: The Vestibule */
.scene-1 {
    background-color: var(--canvas-base);
}

.hero-container {
    text-align: center;
    width: 100%;
}

.hero-text {
    font-family: 'Jost', 'Futura', sans-serif;
    font-weight: 500;
    font-size: clamp(4rem, 10vw, 8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold-display);
    line-height: 1.1;
    margin-bottom: 40px;
}

.hero-char {
    display: inline-block;
    opacity: 0;
    animation: char-fade-in 0.06s ease-out forwards;
    animation-delay: calc(2s + 0.03s * var(--char-index, 0));
}

@keyframes char-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scene-tagline {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    color: var(--body-text);
    line-height: 1.85;
    opacity: 0;
    animation: tagline-fade-in 0.5s ease-out 2s forwards;
    max-width: 600px;
    margin: 0 auto;
}

@keyframes tagline-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* SCENE 2: The Filing Room */
.scene-2 {
    background-color: var(--canvas-base);
    flex-direction: column;
    gap: 60px;
}

.scene-title {
    font-family: 'Jost', sans-serif;
    font-weight: 300;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--warm-accent);
}

.collage-container {
    position: relative;
    width: 100%;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collage-item {
    position: absolute;
    opacity: 0;
    animation: collage-drift-in 0.8s ease-out forwards;
    animation-delay: var(--delay);
}

.document-shape {
    width: 120px;
    height: 170px;
    background: linear-gradient(135deg, rgba(212, 168, 75, 0.15) 0%, rgba(196, 149, 106, 0.08) 100%);
    border: 1px solid var(--warm-accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 0, 0, 0.2);
    border-radius: 1px;

    &:nth-child(1) {
        transform: translateX(-180px) rotate(-8deg);
    }

    &:nth-child(2) {
        transform: translateX(0) rotate(3deg);
        z-index: 2;
    }

    &:nth-child(3) {
        transform: translateX(180px) rotate(-5deg);
    }
}

.seal-shape {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 2px solid var(--seal-red);
    background: rgba(139, 58, 42, 0.08);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3), inset 0 0 15px rgba(139, 58, 42, 0.1);
    position: absolute;
    right: 80px;
    top: 50px;
}

@keyframes collage-drift-in {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.network-diagram {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    animation: fade-in 1s ease-out 0.3s forwards;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.network-line {
    stroke-dasharray: 4 8;
    animation: dash-flow 4s linear infinite;
}

@keyframes dash-flow {
    from {
        stroke-dashoffset: 0;
    }
    to {
        stroke-dashoffset: -12;
    }
}

/* SCENE 3: The Examination */
.scene-3 {
    background-color: var(--scene3-cool);
    flex-direction: column;
    gap: 40px;
}

.seal-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.circular-seal {
    width: clamp(200px, 40vmin, 400px);
    height: clamp(200px, 40vmin, 400px);
    animation: seal-rotate 120s linear infinite;
}

.circular-seal circle {
    stroke: var(--warm-accent);
}

.seal-text {
    font-family: 'IBM Plex Mono', 'IBM Plex', monospace;
    font-size: 12px;
    fill: var(--warm-accent);
    letter-spacing: 0.15em;
    animation: text-counter-rotate 240s linear infinite;
}

@keyframes seal-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes text-counter-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(-360deg);
    }
}

.examination-text {
    text-align: center;
    max-width: 500px;
}

.examination-text p {
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    line-height: 1.85;
    color: rgba(255, 255, 255, 0.8);
}

/* SCENE 4: The Approval */
.scene-4 {
    background-color: var(--canvas-base);
    flex-direction: column;
    gap: 60px;
}

.approval-container {
    position: relative;
    width: 100%;
    height: 300px;
}

.form-lines {
    width: 100%;
    height: 100%;
}

.form-line {
    stroke-dasharray: 100%;
    stroke-dashoffset: 100%;
    animation: line-draw 0.6s ease-out forwards;
}

.form-line:nth-child(1) { animation-delay: 0.2s; }
.form-line:nth-child(2) { animation-delay: 0.4s; }
.form-line:nth-child(3) { animation-delay: 0.6s; }
.form-line:nth-child(4) { animation-delay: 0.8s; }
.form-line:nth-child(5) { animation-delay: 1s; }

@keyframes line-draw {
    from {
        stroke-dashoffset: 100%;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.stamp-approved {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Jost', sans-serif;
    font-weight: 500;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--seal-red);
    border: 3px solid var(--seal-red);
    padding: 20px 40px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
    animation: stamp-pulse 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 1.4s forwards;
}

@keyframes stamp-pulse {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.stamp-approved::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border: 2px solid var(--seal-red);
    border-radius: 4px;
    opacity: 0;
    animation: pulse-ring 0.8s ease-out 1.4s forwards;
}

@keyframes pulse-ring {
    from {
        width: 100%;
        height: 100%;
        opacity: 0.6;
    }
    to {
        width: 300%;
        height: 300%;
        opacity: 0;
    }
}

/* SCENE 5: The Archive */
.scene-5 {
    background-color: var(--scene5-amber);
    flex-direction: column;
    padding-bottom: 200px;
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    width: 100%;
    max-width: 600px;
    perspective: 800px;
}

.archive-item {
    aspect-ratio: 1 / 1.414;
    background: linear-gradient(135deg, rgba(212, 168, 75, 0.12) 0%, rgba(196, 149, 106, 0.06) 100%);
    border: 1px solid var(--warm-accent);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3), 0 0 1px rgba(0, 0, 0, 0.15);
    border-radius: 1px;
    animation: archive-settle 1s ease-out 0.3s forwards;
    animation-delay: calc(0.1s * var(--index, 0));
    transform: perspective(800px) rotateX(5deg) rotateY(0deg);
    opacity: 0;

    &:nth-child(1) { --index: 0; }
    &:nth-child(2) { --index: 1; }
    &:nth-child(3) { --index: 2; }
    &:nth-child(4) { --index: 3; }
    &:nth-child(5) { --index: 4; }
    &:nth-child(6) { --index: 5; }
    &:nth-child(7) { --index: 6; }
    &:nth-child(8) { --index: 7; }
    &:nth-child(9) { --index: 8; }
}

@keyframes archive-settle {
    from {
        opacity: 0;
        transform: perspective(800px) rotateX(15deg) translateY(20px);
    }
    to {
        opacity: 1;
        transform: perspective(800px) rotateX(5deg) translateY(0);
    }
}

.mountain-silhouette {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .sidebar {
        width: 25%;
    }

    .canvas {
        margin-left: 25%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 20%;
    }

    .canvas {
        margin-left: 20%;
    }

    .scene {
        padding: 40px 20px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        display: none;
    }

    .canvas {
        margin-left: 0;
    }
}
