/* --- FONTS --- */

/* Courier Prime - Regular (400) */
@font-face {
    font-family: 'Courier Prime';
    font-style: normal;
    font-weight: 400;
    src: url('../fonts/courier-prime-v11-latin-regular.woff2') format('woff2'),
         url('../fonts/courier-prime-v11-latin-regular.woff') format('woff');
}

/* Courier Prime - Bold (700) */
@font-face {
    font-family: 'Courier Prime';
    font-style: normal;
    font-weight: 700;
    src: url('../fonts/courier-prime-v11-latin-700.woff2') format('woff2'),
         url('../fonts/courier-prime-v11-latin-700.woff') format('woff');
}

/* Dancing Script - Bold (700) */
@font-face {
    font-family: 'Dancing Script';
    font-style: normal;
    font-weight: 700;
    src: url('../fonts/dancing-script-v29-latin-700.woff2') format('woff2'),
         url('../fonts/dancing-script-v29-latin-700.woff') format('woff');
}

/* Permanent Marker - Regular (400) */
@font-face {
    font-family: 'Permanent Marker';
    font-style: normal;
    font-display: swap;
    font-weight: 400;
    src: url('../fonts/permanent-marker-v16-latin-regular.woff2') format('woff2');
}

/* Portugues Arcaico Lectura (400) */
@font-face {
    font-family: 'Portugues Arcaico Lectura';
    font-style: normal;
    font-weight: 400;
    src: url('../fonts/portugues-arcaico-lectura-400.woff2') format('woff2'),
         url('../fonts/portugues-arcaico-lectura-400.woff') format('woff');
}

/* --- BASE & BACKGROUND --- */
#akte-wrapper {
    background-image: url('../images/akte_bg.jpg');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
    width: 100%;
    padding-top: 4rem;
    padding-bottom: 4rem;
    min-height: calc(100vh - 4rem);
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: sans-serif;
    overflow-x: hidden;
}

/* Dimming overlay */
#akte-wrapper::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
    z-index: 1;
}

/* Active dimming state */
#akte-wrapper.dimmed::after {
    opacity: 0.6;
}

.view-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-top: 20px;
    /* Ensure content stays above overlay */
    z-index: 10;
}

.view-container.open-state {
    background: transparent;
    border-radius: 0;
    padding: 20px 0;
}

/* --- CLOSED FOLDER --- */
.folder-closed {
    width: 480px;
    height: 600px;
    background: #2c2c2c;
    position: relative;
    cursor: pointer;
    transform: perspective(1000px) rotateX(20deg) rotateY(0deg) rotateZ(-2deg);
    box-shadow: 20px 30px 40px rgba(0,0,0,0.6);
    border-radius: 4px;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    margin-top: 25vh;
}

.folder-closed:hover {
    transform: perspective(1000px) rotateX(10deg) rotateZ(0deg) scale(1.02);
}

/* --- SEAL & DISABLED STATE --- */
.folder-closed.disabled {
    cursor: default;
    filter: grayscale(0.2);
}

.folder-closed.disabled:hover {
    transform: perspective(1000px) rotateX(20deg) rotateY(0deg) rotateZ(-2deg);
}

.folder-seal {
    position: absolute;
    bottom: 50px;
    right: 40px;
    width: auto;
    height: auto;
    padding: 10px 20px;
    background-color: #b71c1c;
    color: #fff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 3px dashed rgba(255,255,255,0.4);
    box-shadow: 2px 4px 10px rgba(0,0,0,0.5);
    transform: rotate(-15deg);
    z-index: 20;
    pointer-events: none;
}

.folder-seal span {
    font-family: 'Courier Prime', monospace;
    font-weight: bold;
    font-size: 1.2rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    display: block;
    line-height: 1;
    white-space: nowrap;
}

.folder-spine {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 35px;
    background: #1a1a1a;
    border-right: 1px solid #444;
    border-radius: 4px 0 0 4px;
    z-index: 20;
}

.folder-cover {
    margin-left: 35px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(45deg, #2c2c2c, #2c2c2c 8px, #333 8px, #333 9px);
    position: relative;
    z-index: 10;
}

.folder-label {
    background: #f4e1c1;
    color: #222;
    padding: 20px;
    border: 1px solid #aaa;
    text-align: center;
    width: 75%;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    font-family: 'Courier Prime', monospace;
    transform: rotate(1deg);
}

.folder-label h1 {
    margin: 0;
    font-size: 2.3rem;
    border-bottom: 3px solid #222;
    line-height: 1.2;
}

.folder-label p {
    margin: 5px 0 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #d32f2f;
    font-weight: bold;
}

.folder-tabs {
    position: absolute;
    top: -25px;
    right: 20px;
    display: flex;
    gap: 2px;
    z-index: 1;
}

.folder-tab {
    background: #e0d5bc;
    border: none;
    padding: 5px 15px 10px 15px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    color: #333;
    font-family: 'Courier Prime', monospace;
    box-shadow: 0 -2px 3px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    position: relative;
}

.folder-tab:hover {
    transform: translateY(-3px);
    background: #fff;
}

.hint-text {
    margin-top: 30px;
    color: rgba(255,255,255,0.8);
    font-family: 'Courier Prime', monospace;
    background: rgba(0,0,0,0.6);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    display: none;
}

/* --- OPEN FOLDER (VIEW) --- */
.file-content {
    display: flex;
    width: 900px;
    max-width: 90%;
    min-height: 600px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    position: relative;
    transition: opacity 0.3s;
    overflow: visible;
}

/* LEFT SIDE (Cardboard) */
.paper-left {
    flex: 0 0 45%;
    background: #d0bfa0;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZDBiZmEwIi8+CjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiNjM2IwOTAiLz4KPC9zdmc+');
    position: relative;
    padding: 20px;
    border-right: 2px solid rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    border-bottom: none;
}

.close-x {
    position: absolute;
    top: 15px;
    left: 15px;
    font-family: sans-serif;
    font-weight: bold;
    font-size: 1.5rem;
    color: #a00;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    z-index: 10;
}

.close-x:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* RIGHT SIDE (Paper) */
.paper-right {
    flex: 1;
    background: #fdfbf7;
    background-image: linear-gradient(to bottom right, #fffdf5 0%, #f4f0e6 100%);
    position: relative;
    padding: 30px 40px;
    font-family: 'Courier Prime', monospace;
    color: #222;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

/* --- SIDE TABS (Desktop) --- */
.side-tabs {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    z-index: 5;
}

.side-tab {
    background: #ddd;
    border: 1px solid #bbb;
    border-bottom: none;
    font-family: sans-serif;
    font-size: 0.8rem;
    color: #555;
    cursor: pointer;
    border-radius: 5px 5px 0 0;
    width: 120px;
    text-align: center;
    box-shadow: 2px -2px 3px rgba(0,0,0,0.1);
    /* Rotate around bottom-left for correct expansion */
    transform-origin: bottom left;
    transform: rotate(90deg);
    position: absolute;
    left: 100%;
}

.side-tab:nth-child(1) {
    top: 0;
}

.side-tab:nth-child(2) {
    top: 125px;
}

.side-tab.active {
    background: #d32f2f;
    color: white;
    font-weight: bold;
    border-color: #b71c1c;
    z-index: 6;
}

/* --- PHOTOS --- */
.photo-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    margin-top: 0px;
    width: 100%;
}

.polaroid {
    background: white;
    padding: 8px 8px 30px 8px;
    box-shadow: 2px 3px 6px rgba(0,0,0,0.3);
    width: 220px;
    max-width: 90%;
    position: relative;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
}

.polaroid.p1 {
    transform: rotate(-2deg) translateX(-10px);
}

.polaroid.p2 {
    transform: rotate(3deg) translateX(10px);
}

.polaroid:hover {
    transform: scale(1.05) rotate(0deg) !important;
    z-index: 10;
}

.polaroid img {
    width: 100%;
    height: auto;
    filter: sepia(20%) contrast(1.1);
    display: block;
}

.tape {
    position: absolute;
    top: -10px;
    left: 35%;
    width: 30%;
    height: 25px;
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transform: rotate(-2deg);
}

.photo-caption {
    font-family: 'Permanent Marker', cursive;
    font-weight: 400;
    font-size: 1.1rem;
    color: #1a1a1a;
    text-align: center;
    margin-top: 10px;
    line-height: 1.1;
    transform: rotate(-1deg);
}

/* --- TEXT CONTENT --- */
.paper-body {
    flex: 1;
}

.typewriter-title {
    text-align: center;
    text-transform: uppercase;
    text-decoration: underline;
    font-size: 1rem;
    margin-bottom: 5px;
    opacity: 0.7;
}

.typewriter-subtitle {
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 20px;
    border-bottom: 2px solid #222;
    padding-bottom: 5px;
    display: block;
    width: 100%;
}

.data-grid {
    font-size: 0.95rem;
    line-height: 1.4;
}

.data-row {
    margin-bottom: 5px;
    display: flex;
    align-items: baseline;
}

.data-row .label {
    color: #000;
    font-weight: bold;
    width: 150px;
    flex-shrink: 0;
    background: transparent;
    font-size: 0.95rem;
}

.data-row .value {
    color: #b71c1c;
    font-weight: bold;
    font-family: 'Courier Prime', monospace;
}

.data-row.block {
    display: block;
    margin-top: 15px;
}

.data-row.block .label {
    width: 100%;
    margin-bottom: 3px;
    display: block;
}

.data-row.block .value.multiline {
    white-space: pre-wrap;
    padding-left: 10px;
    color: #b71c1c;
    font-style: italic;
    font-size: 0.9rem;
}

/* --- FOOTER --- */
.paper-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 20px;
    margin-bottom: 50px;
    min-height: 70px;
}

.footer-left {
    flex: 0 0 auto;
    margin-right: 20px;
}

.footer-right {
    flex: 1;
    text-align: right;
}

.stamp-imprint {
    border: 3px solid #d32f2f;
    color: #d32f2f;
    font-weight: bold;
    font-size: 2.0rem;
    width: fit-content;
    padding: 2px 6px;
    text-transform: uppercase;
    transform: rotate(-8deg);
    opacity: 0.85;
    mix-blend-mode: multiply;
    display: block;
    mask-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=');
}

.sig-label {
    display: block;
    font-size: 0.7rem;
    opacity: 0.6;
}

.sig-handwriting {
    font-family: 'Dancing Script', cursive;
    font-size: 1.3rem;
    color: #0d47a1;
}

/* --- NAVIGATION ARROWS (Simplified) --- */
/* The arrow symbol itself */
.nav-arrow {
    font-family: 'Courier Prime', monospace; /* Sticking to theme */
    font-size: 2.5rem;
    font-weight: bold;
    color: #444;
    transition: transform 0.2s, color 0.2s;
    user-select: none;
}

/* Hover effect on the arrow text */
.dog-ear-left:hover .nav-arrow,
.dog-ear-left-mobile:hover .nav-arrow {
    transform: translateX(-3px);
    color: #d32f2f; /* Red on hover */
}

.dog-ear-right:hover .nav-arrow {
    transform: translateX(3px);
    color: #d32f2f;
}

/* --- NAVIGATION CLICK ZONES --- */
/* Common styles for the click areas in the corners */
.dog-ear-left,
.dog-ear-right,
.dog-ear-left-mobile {
    position: absolute;
    bottom: 0;
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: flex-end; /* Align arrow to bottom */
    background: transparent;
}

/* Desktop LEFT (on cardboard) */
.dog-ear-left {
    left: 0;
    justify-content: flex-start;
    padding: 0 0 0 15px; /* Adjusted bottom padding */
}

/* Desktop RIGHT (on paper) */
.dog-ear-right {
    right: 0;
    justify-content: flex-end;
    padding: 0 20px 0 0; /* Adjusted bottom padding */
}

/* Mobile LEFT (on paper, hidden by default on desktop) */
.dog-ear-left-mobile {
    display: none;
    left: 0;
    justify-content: flex-start;
    padding: 0 0 0 15px;
}

.pagination-info {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: #aaa;
}

/* --- WATERMARK --- */
.watermark {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('/user/images/logo_symbol.png');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 70%;
    opacity: 0.08;
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 0;
}

.paper-body {
    flex: 1;
    position: relative;
    z-index: 1;
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
    .folder-closed {
        width: 80%;
        max-width: 340px;
        height: 450px;
        margin-top: 30vh;
    }

    .folder-seal {
        bottom: 30px;
        right: 20px;
        padding: 8px 15px;
    }

    .folder-seal span {
        font-size: 0.9rem;
    }

    /* Side-by-Side Tabs */
    .side-tabs {
        flex-direction: row;
        width: 100%;
        gap: 0;
        top: -40px;
        right: auto;
        left: 0;
        height: 40px;
        flex-wrap: nowrap;
    }

    .side-tab {
        position: relative;
        transform: none;
        top: 0 !important;
        right: auto !important;
        left: auto;
        width: 50%;
        flex: 1 0 50%;
        border-bottom: 1px solid #bbb;
        margin-bottom: -1px;
        margin-left: 0;
    }

    .file-content {
        flex-direction: column;
        width: 95%;
        height: auto;
    }

    .paper-left {
        flex: none;
        width: 100%;
        border-right: none;
        padding: 15px;
    }

    .photo-grid {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        margin-top: 20px;
        gap: 15px;
        min-height: auto;
    }

    .polaroid {
        width: 45%;
        max-width: 140px;
        transform: none;
    }

    .polaroid.p1 {
        transform: rotate(-2deg) translateY(-5px);
    }

    .polaroid.p2 {
        transform: rotate(3deg) translateY(5px);
    }

    .photo-caption {
        font-size: 0.9rem;
    }

    /* Hide Desktop Nav */
    .desktop-nav {
        display: none;
    }

    /* Show Mobile Left Nav */
    .mobile-nav {
        display: flex; /* Uses flex from class definition */
    }

    .paper-right {
        padding: 15px 15px 60px 15px;
        margin-top: 40px;
        /* Ensure paper-right has enough space at bottom for arrows */
        position: relative;
    }

    .paper-footer {
        flex-direction: row;
        margin-bottom: 0;
    }
}

/* --- MOBILE LANDSCAPE FIX (Final Polish) --- */
@media screen and (orientation: landscape) and (max-height: 850px) {

    #akte-wrapper {
        padding: 0;
        height: 100vh;
        height: 100dvh;
        width: 100vw;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center; /* Center folder horizontally */
        background-attachment: fixed;
    }

    /* --- CLOSED FOLDER --- */
    .folder-closed {
        height: 85dvh;
        width: auto;
        aspect-ratio: 1 / 1.3;
        max-width: none;
        margin-top: 0;
    }

    .folder-label {
        padding: 1vh;
        width: 80%;
    }

    .folder-label h1 {
        font-size: 7vh;
        border-bottom-width: 2px;
        line-height: 1.1;
    }

    .folder-label p {
        font-size: 2.5vh;
        margin-top: 1vh;
    }

    .folder-seal {
        bottom: 3vh;
        right: 3vh;
        padding: 1vh 2vh;
    }

    .folder-seal span {
        font-size: 3vh;
    }

    /* --- OPEN FOLDER --- */
    .view-container.open-state {
        padding: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        /* Align left to leave room for tabs */
        justify-content: flex-start;
        padding-left: 2vw;
    }

    .file-content {
        min-height: 0 !important;
        /* Reduce width to make room for tabs */
        width: 85vw;
        height: 90dvh; /* Spacing top/bottom */
        flex-direction: row;
        box-shadow: none;
        filter: drop-shadow(0 5px 15px rgba(0,0,0,0.5));
        /* Force right margin */
        margin-right: 10vw;
    }

    /* --- LEFT SIDE (Stacked Photos) --- */
    .paper-left {
        width: 35%;
        flex: 0 0 35%;
        padding: 10px;
        border-right: 2px solid rgba(0,0,0,0.1);
        border-bottom: none;
        clip-path: none !important;
        position: relative;
        overflow: visible; /* Important for overlap visibility */
    }

    .photo-grid {
        display: block;
        position: relative;
        width: 100%;
        height: 100%;
        margin-top: 0;
    }

    .polaroid {
        position: absolute;
        /* Make smaller */
        width: 100px;
        max-width: 90%;
        /* Center */
        left: 50%;
        padding: 4px 4px 15px 4px;
        transition: all 0.3s ease;
        z-index: 5;
    }

    /* Image 1: Top, slightly rotated */
    .polaroid.p1 {
        top: 15%; /* Percentage top to avoid clipping */
        transform: translateX(-55%) rotate(-5deg);
    }

    /* Image 2: Below, slightly offset */
    .polaroid.p2 {
        top: 25%;
        transform: translateX(-45%) rotate(5deg);
        z-index: 6;
    }

    /* Hover/Click Effect */
    .polaroid:hover,
    .polaroid:active,
    .polaroid:focus {
        z-index: 50;
        transform: translateX(-50%) rotate(0deg) scale(1.1);
    }

    .photo-caption {
        font-size: 0.6rem;
        margin-top: 2px;
    }

    /* --- RIGHT SIDE (Data) --- */
    .paper-right {
        flex: 1;
        width: 65%;
        padding: 15px 20px 5px 15px; /* Less padding right */
        margin-top: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .paper-body {
        flex: 1;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .paper-footer {
        flex: 0 0 auto;
        margin-top: 5px;
        margin-bottom: 5px;
        min-height: auto;
        padding-top: 5px;
        border-top: 1px dashed rgba(0,0,0,0.1);
    }

    /* --- TYPOGRAPHY CORRECTIONS --- */
    .typewriter-title {
        font-size: 0.8rem;
        margin-bottom: 2px;
        opacity: 0.7;
    }

    .typewriter-subtitle {
        font-size: 1.0rem;
        margin-bottom: 5px;
        padding-bottom: 2px;
        border-bottom-width: 1px;
    }

    .data-grid {
        font-size: 0.85rem;
        line-height: 1.2;
    }

    .data-row {
        margin-bottom: 2px;
    }

    .data-row.block {
        margin-top: 5px;
    }

    .data-row .label {
        width: 100px;
        font-size: 0.85rem;
    }

    /* FIX FOR HUGE FONT SIZE */
    .data-row.block .value.multiline {
        font-size: 0.85rem !important; /* Force same size */
        line-height: 1.3;
        font-weight: bold; /* Keep bold, normalize size */
        color: #b71c1c;
    }

    .stamp-imprint {
        font-size: 0.9rem;
        border-width: 2px;
        margin-left: -5px;
    }

    .sig-label {
        font-size: 0.5rem;
        margin-bottom: 0;
    }

    .sig-handwriting {
        font-size: 0.9rem;
        line-height: 1;
    }

    /* --- TABS (Now visible!) --- */
    .side-tabs {
        top: 10px;
        right: 0;
        /* Folder is narrower (85vw), space available on right */
    }

    .side-tab {
        width: 60px;
        padding: 2px 0;
        font-size: 0.7rem;
        left: 100%; /* Sticks to right of folder */
        top: 0 !important;
        background: #ddd; /* Ensure color is present */
    }

    .side-tab:nth-child(2) {
        top: 70px !important;
    }

    /* --- NAVIGATION --- */
    .desktop-nav {
        display: flex;
    }

    .dog-ear-left-mobile {
        display: none;
    }

    .dog-ear-left {
        width: 40px;
        height: 40px;
        padding-left: 5px;
        padding-bottom: 0; /* Force position to bottom */
    }

    .dog-ear-right {
        width: 40px;
        height: 40px;
        padding-right: 5px;
        padding-bottom: 0; /* Force position to bottom */
    }

    .nav-arrow {
        font-size: 1.5rem;
    }

    .close-x {
        font-size: 1.5rem;
        top: 5px;
        left: 10px;
    }

    .pagination-info {
        font-size: 0.6rem;
        bottom: 2px;
    }
}
