@import url('https://fonts.googleapis.com/css2?family=Special+Elite&display=swap');

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

html {
    height: 100%;
}

/* SVG filter for noise texture */
@keyframes subtle-noise {
    0% { filter: url(#noise) brightness(100%); }
    50% { filter: url(#noise) brightness(98%); }
    100% { filter: url(#noise) brightness(100%); }
}

body {
    height: 100%;
    overflow: hidden; /* Prevent scrolling the body */
    font-family: 'Courier New', Courier, monospace; /* Fallback font */
    /* Noisy background with gradient */
    background: linear-gradient(to bottom left, #b08d57, #8a6d3b 60%, #3a3f44 95%);
    position: relative;
    animation: subtle-noise 8s infinite;
    display: flex; /* Needed for centering the carousel */
    justify-content: center;
    align-items: center;
    color: #000; /* Default text color to black */
}

/* Noise overlay */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.1'/%3E%3C/svg%3E");
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

.carousel-container {
    width: 100%;
    height: 100%; /* Use full viewport height */
    overflow: hidden;
    position: relative;
    /* Ensure container allows centering of its children */
    display: flex;
    align-items: center;
    justify-content: center; 
}

/* Container for the single visible dossier */
#dossier-display {
    position: relative; /* Crucial for positioning absolute children */
    width: 800px;  /* Keep original dimensions for scaling calculation */
    height: 1050px; /* Keep original dimensions for scaling calculation */
    transform-origin: center center; /* Scale from the center */
    /* No margin/padding needed here, handled by children/body */
}

/* The Dossier 'Paper' */
.dossier-page {
    min-width: 800px; /* Fixed width for the paper */
    max-width: 800px;
    height: 1050px; /* Fixed height for the paper */
    background-color: #f0e8d9; /* More authentic aged paper color */
    /* Paper texture with subtle stains */
    background-image: 
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='500' height='500' viewBox='0 0 800 800'%3E%3Cdefs%3E%3Cfilter id='paper-texture' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.8' numOctaves='4' stitchTiles='stitch' result='noise'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 0.03 0' result='texture'/%3E%3C/filter%3E%3C/defs%3E%3Crect width='100%25' height='100%25' filter='url(%23paper-texture)' fill='transparent'/%3E%3Ccircle cx='150' cy='420' r='20' fill='%23d3bc9a' opacity='0.07'/%3E%3Cellipse cx='650' cy='300' rx='40' ry='30' fill='%23c2aa87' opacity='0.05'/%3E%3Cellipse cx='300' cy='700' rx='80' ry='30' fill='%23bb9d78' opacity='0.03'/%3E%3C/svg%3E");
    border: 1px solid #bbb;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.35);
    margin: 0 50px; /* Add horizontal margin for spacing between slides */
    padding: 30px 40px; /* Padding inside the paper */
    position: relative; /* For absolute positioning of elements like photo */
    font-family: 'Special Elite', 'Courier New', monospace; /* Typewriter font */
    /* Display grid for main layout */
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* Example: 6 columns */
    grid-template-rows: auto auto auto auto auto 1fr; /* Header, fields, redacted section */
    gap: 0px; /* No gap needed, control via padding/margins */
    border-top: 2px solid #444; /* Thicker top border */
    position: relative; /* Needed for pseudo-elements */
}

.dossier-page::before,
.dossier-page::after {
  content: "";
  position: absolute;
  height: 95%;
  width: 99%;
  background-color: #e9e3d4; /* Slightly different aged paper for stacked pages */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='500' height='500' viewBox='0 0 800 800'%3E%3Cdefs%3E%3Cfilter id='paper-texture' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.8' numOctaves='4' stitchTiles='stitch' result='noise'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 0.03 0' result='texture'/%3E%3C/filter%3E%3C/defs%3E%3Crect width='100%25' height='100%25' filter='url(%23paper-texture)' fill='transparent'/%3E%3C/svg%3E");
  box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.25);
  border: 1px solid #ccc;
}

.dossier-page::before {
  right: 15px;
  top: 0;
  transform: rotate(-1deg);
  z-index: -1; /* Behind main page */
}

.dossier-page::after {
  top: 5px;
  right: -5px;
  transform: rotate(1deg);
  z-index: -2; /* Behind ::before */
}

/* Dossier Transition Animations */
@keyframes slideFadeOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-20px); /* Slide left slightly */
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideFadeInFromRight {
  from {
    opacity: 0;
    transform: translateX(20px); /* Slide right slightly */
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.dossier-exit {
  animation: slideFadeOutLeft 0.4s ease-out forwards;
  position: absolute; /* Keep it out of normal flow during animation */
  width: inherit; /* Maintain width */
  top: 0; /* Align top */
  left: 0; /* Align left */
}

.dossier-enter {
  animation: slideFadeInFromRight 0.4s ease-in forwards;
  position: absolute; /* Keep it out of normal flow during animation */
  width: inherit; /* Maintain width */
  top: 0; /* Align top */
  left: 0; /* Align left */
}

/* --- Header Elements --- */
.header-logo {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    width: 60px;
    height: 60px;
    border: 1px solid #888;
    background-color: #e0e0e0;
    border-radius: 50%;
    margin: 10px 0 10px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    color: #555;
    text-align: center;
}

.header-title {
    grid-column: 2 / 6;
    grid-row: 1 / 2;
    text-align: center;
    font-size: 1.8em;
    font-weight: bold;
    letter-spacing: 2px;
    padding-top: 10px;
    color: #000;
}

.header-subtitle {
    grid-column: 2 / 6;
    grid-row: 2 / 3;
    text-align: center;
    font-size: 0.8em;
    letter-spacing: 1px;
    color: #333;
    margin-top: -5px; /* Pull closer to title */
    padding-bottom: 10px;
    border-bottom: 1.5px solid #555;
}

.case-info {
    grid-column: 6 / 7;
    grid-row: 1 / 3;
    font-size: 0.8em;
    padding: 15px 10px 0 0;
    text-align: right;
    position: relative; /* For the circle */
}

.case-no {
    display: block;
    margin-bottom: 10px;
}

.circled-number {
    display: inline-block;
    border: 1px solid #555;
    border-radius: 50%;
    padding: 5px 8px;
    margin-left: 5px;
    /* Add hand-drawn circle effect later if possible */
}

/* --- Agent Photo --- */
.agent-photo {
    position: absolute;
    top: 20px; /* Adjust overlap */
    left: -20px; /* Adjust overlap */
    width: 180px; /* Size from image */
    height: 220px; /* Size from image */
    background-color: #d0d0d0;
    border: 1px solid #555;
    z-index: 5; /* Ensure it's above fields */
    display: flex;
    justify-content: center;
    align-items: center;
    color: #666;
    font-size: 14px;
    font-weight: bold;
    transform: rotate(-2deg); /* Slight tilt */
}

/* --- Field Layout --- */
.fields-grid {
    grid-column: 1 / 7;
    grid-row: 3 / 6;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(4, auto); /* Rows for fields */
    border: 1px solid #aaa; /* Outer border for the fields block */
    border-top: none; /* Remove top border as it's part of header subtitle line */
    margin-top: -1px; /* Overlap with header border */
    padding-top: 10px; /* Space above first row */
}

.field-item {
    border-right: 1px solid #aaa;
    border-bottom: 1px solid #aaa;
    padding: 5px 8px;
    position: relative; /* For absolute label */
    min-height: 45px; /* Ensure minimum height */
    display: flex;
    align-items: flex-end; /* Align content bottom */
}

.field-item:last-child {
    border-right: none;
}

/* Spanning specific fields */
.field-item.span-2 { grid-column: span 2; }
.field-item.span-3 { grid-column: span 3; }
.field-item.span-4 { grid-column: span 4; }
.field-item.span-6 { grid-column: span 6; border-right: none;}

/* Adjust borders for grid layout */
.fields-grid .field-item:nth-child(6n) { border-right: none; } /* No right border on last column item */
.fields-grid > .field-item:nth-last-child(-n+6) { border-bottom: none; } /* No bottom border on last row items */
/* Manually remove bottom border for items on the last *visible* row */
.field-item.occupation { border-bottom: none; }
.field-item.gender { border-bottom: none; }


.field-label {
    position: absolute;
    top: 3px;
    left: 8px;
    font-size: 0.7em;
    color: #444;
    text-transform: uppercase;
}

.field-value {
    font-size: 1.0em;
    color: #000;
    width: 100%;
    margin-top: 15px; /* Space below label */
    line-height: 1.3;
}

/* --- Censorship Band --- */
.censored-band {
    display: inline-block; /* Or block if it's replacing a whole paragraph */
    background-color: #000;
    color: #000; /* Hide any accidental text spillover */
    height: 1.1em; /* Match typical line height */
    vertical-align: text-bottom; /* Align with text */
    padding: 0 5px; /* Give a little width even if empty */
    margin: 0 2px; /* Spacing */
    overflow: hidden;
    white-space: nowrap;
    text-indent: -9999px; /* Hide text */
}

.censored-block {
    display: block;
    background-color: #000;
    height: 1.5em;
    margin: 4px 0; /* Spacing between bands */
}

/* --- Redacted Section --- */
.redacted-section {
    grid-column: 1 / 7;
    grid-row: 6 / 7;
    padding: 15px 10px;
    border-top: 1.5px solid #555; /* Separator line */
}

/* --- Footer/Misc Elements --- */
.vertical-text {
    position: absolute;
    right: -15px; /* Position outside the main padding */
    bottom: 100px;
    transform: rotate(90deg);
    transform-origin: bottom right;
    font-size: 0.8em;
    color: #555;
    letter-spacing: 1px;
}

/* --- Carousel Buttons (Adjust positioning) --- */
.carousel-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    padding: 20px 15px;
    cursor: pointer;
    font-size: 24px;
    z-index: 10;
    transition: background-color 0.3s ease;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.carousel-button:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.prev {
    /* Position closer to the left edge of the dossier */
    left: calc(50% - 470px);
}

.next {
    /* Position closer to the right edge of the dossier */
    right: calc(50% - 470px);
}

/* REMOVE OLD/UNUSED STYLES */
.details-container,
.field-group,
.stamp {
    display: none; /* Or simply delete them */
}

/* ------------------------------- */
/* MOBILE RESPONSIVE STYLES */
/* ------------------------------- */

@media screen and (max-width: 900px) {
    /* Override the animations for mobile - disable all animations */
    .dossier-exit, .dossier-enter {
        animation: none;
    }
    
    /* Add a simple fade for mobile */
    @keyframes mobileFadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    .mobile-fade-in {
        animation: mobileFadeIn 0.3s ease-in forwards;
        opacity: 0; /* Start invisible */
    }
    
    /* Ensure dossier-page is properly positioned */
    .dossier-page {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        margin: 0 auto;
        transform: none; /* Ensure no transform is applied to the page itself */
    }

    /* Container adjustments */
    #dossier-display {
        /* Keep width constraints if needed, or remove if JS handles all scaling */
        /* min-width: 90vw; REMOVED */ 
        /* max-width: 90vw; REMOVED */
        /* height: 80vh; REMOVED - Let JS scaling handle height */
        position: relative; /* Ensure this is preserved */
    }
    
    /* Dossier page adjustments */
    .dossier-page {
        /* Width/Height should match the intrinsic size (800x1050) */
        /* The container #dossier-display will be scaled by JS */
        /* min-width: 90vw; REMOVED */
        /* max-width: 90vw; REMOVED */
        /* height: 80vh; REMOVED */
        padding: 20px;
        margin: 0;
        font-size: 0.9em; /* Base font size for mobile */
        box-sizing: border-box; 
    }
    
    /* Adjust stack effect for smaller screens */
    .dossier-page::before, 
    .dossier-page::after {
        width: 97%;
        height: 97%;
        box-sizing: border-box; /* Ensure consistent sizing */
    }
    
    /* Button positioning for mobile */
    .carousel-button {
        width: 40px;
        height: 40px;
        padding: 10px;
        font-size: 18px;
    }
    
    .prev {
        left: 5px;
    }
    
    .next {
        right: 5px;
    }
    
    /* Header elements */
    .header-title {
        font-size: 1.4em;
        letter-spacing: 1px;
    }
    
    .header-logo {
        width: 40px;
        height: 40px;
    }
    
    /* Photo and field adjustments */
    .agent-photo {
        width: 100%;
        max-width: 120px;
    }
    
    .field-label, .field-value {
        font-size: 0.8em;
    }
    
    /* Redacted bands - thinner on mobile */
    .redacted-band {
        height: 1.2em;
        margin: 3px 0;
    }
}

/* Even smaller screens */
@media screen and (max-width: 600px) {
    .dossier-page {
        padding: 15px;
        font-size: 0.8em;
    }
    
    .header-title {
        font-size: 1.2em;
    }
    
    .carousel-button {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    /* Adjust grid layout for very small screens */
    .dossier-page {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .header-title {
        grid-column: 2 / 5;
    }
    
    /* Stack the fields vertically on very small screens */
    .field-row {
        flex-direction: column;
    }
    
    .field-label, .field-value {
        padding: 2px 0;
    }
}
