/* --- 2. Brand & Visual System --- */
:root {
    --clr-black: #0c0c0e;
    --clr-gunmetal: #353535;
    --clr-silver: #c4c4c4;
    --clr-silver-light: #ffffff;
    --clr-orange-alert: #e84e0f;
    --clr-blue-focus: #19b9f5;
    --font-primary: 'Source Sans Pro', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --transition-speed: 400ms;
}

/* --- Global & Accessibility --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    background-color: var(--clr-black);
    color: var(--clr-silver);
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Page Transition System --- */
.page {
    display: none;
    opacity: 0;
    position: absolute; /* Prevent layout shifts during transition */
    top: 0;
    left: 0;
    width: 100%;
}

.page.active {
    display: block;
    position: relative; /* Take back its space in the document flow */
    animation: fadeIn var(--transition-speed) forwards;
}

.page.fading-out {
    display: block; /* Make it visible for the animation */
    animation: fadeOut var(--transition-speed) forwards;
}

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

/* --- 5. & 6. Interaction / Focus --- */
*:focus-visible {
    outline: 2px solid var(--clr-blue-focus);
    outline-offset: 2px;
}

@keyframes formShake { 0%, 100% { transform: translateX(0); } 10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); } 20%, 40%, 60%, 80% { transform: translateX(5px); } }
@keyframes vhsFlash { 0%, 100% { opacity: 1; filter: none; } 50% { opacity: 0.8; filter: brightness(1.5) contrast(1.2) saturate(0.8); } }
@keyframes greyOut { to { filter: saturate(0) brightness(0.7); pointer-events: none; } }

.shake { animation: formShake 0.5s ease-in-out; }
.vhs-flash { animation: vhsFlash 0.3s steps(2, end); }
.completed { animation: greyOut 1s 24s forwards; }

/* --- 4.1 Login Page --- */
#login-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    background-color: #000;
    background-image: 
        radial-gradient(ellipse at center, rgba(12, 12, 14, 0.2) 0%, rgba(12, 12, 14, 1) 70%),
        repeating-linear-gradient(rgba(255, 255, 255, 0.03) 0, rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 4px);
    background-size: cover, auto;
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header img {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--clr-silver);
    letter-spacing: 13px; /* Key spec */
    text-transform: uppercase;
}

.login-form {
    width: 100%;
    max-width: 380px;
}

.form-field {
    margin-bottom: 1.5rem;
}

.form-field input {
    width: 100%;
    background: none;
    border: 1px solid var(--clr-gunmetal);
    padding: 0.75rem 1rem;
    color: var(--clr-silver);
    font-family: var(--font-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-field input:focus {
    border-color: var(--clr-blue-focus);
    outline: none;
}

.btn {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--clr-gunmetal);
    border: 1px solid var(--clr-gunmetal);
    color: var(--clr-silver);
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.btn:hover {
    border: 1px solid var(--clr-silver-light);
    background: var(--clr-black);
}

.login-feedback {
    color: var(--clr-orange-alert);
    margin-top: -1rem;
    margin-bottom: 1rem;
    height: 1.5em;
    opacity: 0;
    transition: opacity 0.3s;
    font-family: var(--font-mono);
}

.login-feedback.visible {
    opacity: 1;
}

/* --- Shared Secure Page Layout --- */
.secure-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-nav {
    display: flex;
    align-items: center;
    background-color: var(--clr-gunmetal);
    padding: 0.5rem 2rem;
    border-bottom: 1px solid var(--clr-black);
}

.nav-logo {
    width: 40px;
    height: 40px;
}

.nav-back-link {
    color: var(--clr-silver);
    text-decoration: none;
    margin-left: 1rem;
}

.main-content {
    flex-grow: 1;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.main-footer {
    padding: 0.5rem 2rem;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: rgba(196, 196, 196, 0.4);
    border-top: 1px solid var(--clr-gunmetal);
}

/* --- 4.2 Dashboard --- */
.projects-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(3, 1fr);
    transition: opacity 0.2s;
}

.project-card {
    background: var(--clr-gunmetal);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s;
}

.project-card:active { /* 5. Micro UX on click */
    transform: scale(0.98);
}

.card-image-wrapper {
    overflow: hidden;
}

.project-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    border-radius: 4px 4px 0 0;
    transition: transform 0.3s ease, filter 0.3s ease, border 0.3s ease;
}

.project-card:hover img {
    transform: scale(1.05); /* 5% zoom */
    filter: brightness(1.05); /* 5% brightness */
    border: 1px solid var(--clr-silver);
}

.card-code {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--clr-orange-alert);
    color: var(--clr-black);
    font-family: var(--font-mono);
    padding: 0.25rem 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.card-content {
    padding: 1rem;
}

.card-content h3 {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--clr-silver);
}

.card-content p {
    font-size: 0.9rem;
    opacity: 0.8;
    color: var(--clr-silver);
}

/* --- 4.3 Project Page --- */
.project-hero {
    height: 200px;
    background-size: cover;
    background-position: center center;
    background-attachment: fixed; /* Parallax effect */
    position: relative;
    margin: -2rem -2rem 2rem -2rem; /* Bleed to edges */
}

.project-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.project-body {
    display: flex;
    gap: 2rem;
}

.project-article {
    max-width: 68ch; /* 68 characters line length */
    flex-grow: 1;
}

.project-article h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.project-article p {
    margin-bottom: 1.5em;
}

.project-margin-notes {
    flex-shrink: 0;
    width: 150px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: rgba(196, 196, 196, 0.5);
}

.margin-note {
    margin-bottom: 2rem;
}

.photographic-plate {
    margin: 2rem 0;
}

.photographic-plate img {
    max-width: 600px;
    width: 100%;
    height: auto;
    border: 1px solid var(--clr-gunmetal);
    cursor: pointer;
}

.decryption-section {
    border-top: 1px solid var(--clr-gunmetal);
    padding-top: 2rem;
    margin-top: 2rem;
    max-width: 400px;
}

.decryption-section p {
    font-style: italic;
    opacity: 0.7;
    margin-bottom: 1rem;
}

.decryption-form {
    display: flex;
    gap: 1rem;
}

.decryption-form input {
    flex-grow: 1;
    background: none;
    border: 1px solid var(--clr-gunmetal);
    padding: 0.5rem 0.75rem;
    color: var(--clr-silver);
    font-family: var(--font-mono);
}

.decryption-form input:focus {
    border-color: var(--clr-blue-focus);
    outline: none;
}

.decryption-form .btn { width: auto; }

.decryption-feedback {
    color: var(--clr-orange-alert);
    font-family: var(--font-mono);
    margin-top: 0.5rem;
    height: 1.2em;
}

/* --- Lightbox --- */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s;
}

.lightbox.visible { display: flex; }
.lightbox img { max-width: 90%; max-height: 80%; }
.lightbox-close { position: absolute; top: 20px; right: 35px; color: #f1f1f1; font-size: 40px; font-weight: bold; cursor: pointer; }

/* --- 4.4 Experiment Reveal Page --- */
.reveal-alert {
    background: var(--clr-orange-alert);
    color: var(--clr-black);
    padding: 0.75rem 2rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-align: center;
    margin: -2rem -2rem 2rem -2rem; /* Bleed */
}

.reveal-content details {
    border: 1px solid var(--clr-gunmetal);
    margin-bottom: 1rem;
}

.reveal-content summary {
    padding: 0.75rem 1.25rem;
    background: var(--clr-gunmetal);
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 1px;
    user-select: none;
}

.reveal-content summary:hover { background: #4a4a4a; }
.reveal-content div { padding: 1.5rem; }

.final-cta {
    background: var(--clr-gunmetal);
    border: 1px solid var(--clr-orange-alert);
    padding: 2rem;
    margin-top: 3rem;
    font-family: var(--font-mono);
    white-space: pre-wrap;
    line-height: 1.8;
}

/* --- 6. Responsiveness --- */
/* Tablet: 600px - 1023px */
@media (max-width: 1023px) {
    .projects-grid { grid-template-columns: repeat(2, 1fr); }
    .project-body { flex-direction: column; }
    .project-margin-notes { width: 100%; order: -1; margin-bottom: 2rem; display: flex; gap: 2rem; }
    .margin-note { margin-bottom: 0; }
}

/* Mobile: < 600px */
@media (max-width: 599px) {
    .main-content { padding: 1.5rem 1rem; }
    .main-nav { padding: 0.5rem 1rem; }
    .main-footer { padding: 0.5rem 1rem; text-align: center; }
    .login-header h1 { font-size: 1rem; letter-spacing: 8px; }
    .projects-grid { grid-template-columns: 1fr; }
    .project-article h2 { font-size: 2rem; }
    .project-margin-notes { flex-direction: column; gap: 1rem; }
    .decryption-form { flex-direction: column; }
    .decryption-form .btn { width: 100%; }
}