/* Navigation Buttons in Modal */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0);
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    padding: 10px;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    user-select: none;
}

.modal-nav:hover {
    background: var(--accent-color);
    color: #000;
}

.modal-nav-prev { left: 5vw; }
.modal-nav-next { right: 5vw; }

/* =============================================
   LAYOUT & CONTAINER
   ============================================= */

/* We assume writeups pages will also be wrapped in .wrapper > .interface-frame 
   If not, we style the container to fit.
*/

.writeups-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0;
}

/* GRID SETTINGS */
.writeups-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
    margin-top: 1.5rem;
}

.writeup-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.4rem;
    background: rgba(0, 0, 0, 0.30);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    text-decoration: none;
    transition: var(--liquid-transition);
}

.writeup-card:hover {
    border-color: var(--glass-border-hover);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), var(--glass-glow);
}

.writeup-card-header {
    margin-bottom: 1rem;
}

.badge-row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap; /* Forced single line as per request */
    gap: 0.5rem;
    overflow: hidden; /* Prevent spillover */
}

.writeup-date-badge {
    font-family: 'Cascadia Code', monospace;
    font-size: 0.65rem;
    color: var(--dim-text);
    padding: 3px 10px;
    background: rgba(148, 163, 184, 0.05);
    border: 1.5px solid rgba(148, 163, 184, 0.15);
    border-radius: 100px;
    letter-spacing: 0.2px;
    opacity: 0.7;
    flex-shrink: 0;
}

.platform-badge {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 100px;
    letter-spacing: 0.8px;
    white-space: nowrap;
    flex-shrink: 0;
    border: 1.5px solid transparent;
}

.platform-htb {
    background: rgba(159, 239, 0, 0.15);
    color: #9fef00;
    border-color: #9fef00;
}

.platform-sthack {
    background: rgba(255, 45, 120, 0.15);
    color: #ff2d78;
    border-color: #ff2d78;
}

.platform-mars {
    background: rgba(184, 204, 0, 0.15);
    color: #b8cc00;
    border-color: #b8cc00;
}

.difficulty-badge {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 100px;
    background: rgba(148, 163, 184, 0.05);
    border: 1.5px solid rgba(148, 163, 184, 0.15);
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.os-icon {
    width: 14px;
    height: 14px;
    filter: brightness(0) invert(1);
    opacity: 0.7;
    margin-left: 2px;
}

.writeup-card-title {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    color: #FFF;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.writeup-card-desc {
    font-size: 0.8rem;
    color: var(--dim-text);
    margin-top: 0.8rem;
    line-height: 1.5;
    opacity: 0.8;
}

.os-icon {
    width: 16px;
    height: 16px;
    opacity: 0.9;
    /* Force en blanc pur/lumineux */
    filter: brightness(0) invert(1);
}

/* =============================================
   ARTICLE CONTENT
   ============================================= */

.writeup-content {
    background: transparent; /* Handled by layout now */
    border: none;
    padding: 0;
    box-shadow: none;
    color: var(--text-color);
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
}

.writeup-content .page-title {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    font-size: 2.5rem;
    color: var(--accent-color);
    text-align: center; /* Centered */
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1.5rem;
    margin-bottom: 2.5rem;
    background: none;
}

/* Removed ::after pseudo-element for cleaner look */

.writeup-content h1, 
.writeup-content h2, 
.writeup-content h3 {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.3;
}

.writeup-content h1 {
    font-size: 2.2rem;
    color: #ffffff;
    border: none;
    padding: 0;
    text-align: center;
    text-transform: none;
    letter-spacing: -0.5px;
    margin-bottom: 2rem;
    width: 100%;
    text-shadow: none;
}

.writeup-content h1.glitch-hover:hover {
    color: #ffffff;
    text-shadow: none;
}

html[data-theme="light"] .writeup-content h1,
html[data-theme="light"] .writeup-content h1.glitch-hover:hover {
    color: #000000;
    text-shadow: none;
}

.writeup-content h2 { 
    font-size: 1.6rem; 
    color: var(--accent-color);
    padding-bottom: 0.3rem; 
    margin-top: 3rem;
    letter-spacing: 0px;
    text-transform: none;
}

.writeup-content h3 { 
    font-size: 1.3rem; 
    color: #e0e0e0;
    margin-top: 2rem;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
}

.writeup-content p, .writeup-content li {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-color);
}

.writeup-content a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid var(--dim-text);
    transition: border-color 0.2s;
}

.writeup-content a:hover {
    border-bottom-color: var(--accent-color);
}

/* Code Blocks */
.writeup-content pre.code {
    background: transparent; /* Background handled by window */
    border: none; /* Border handled by window */
    border-radius: 0;
    padding: 1rem;
    margin: 0;
    overflow-x: auto;
}

.writeup-content code {
    /* User Request: "Caskadia" (Cascadia Code) and "meme taille" */
    font-family: 'Cascadia Code', 'SFMono-Regular', Consolas, monospace;
    font-size: 0.92em; /* Same size as surrounding text (usually 1rem) */
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
    padding: 0.2em 0.4em; /* Slightly tighter padding for inline */
    border-radius: 4px;
}

.writeup-content pre.code code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.95em; /* Block code can be slightly smaller for density, or 1em if strict */
}

/* Syntax Highlighting - Cyberpunk Neon */
code[class*="language-"],
pre[class*="language-"] {
    color: #e0e0e0;
    text-shadow: none;
    font-family: 'Cascadia Code', 'SFMono-Regular', Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    direction: ltr;
    text-align: left;
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    line-height: 1.5;
    tab-size: 4;
    hyphens: none;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #5c6370; /* Grey */
    font-style: italic;
}

.token.punctuation {
    color: #abb2bf; /* Light Grey */
}

.token.namespace {
    opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
    color: #f0aa60;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #a8e068;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #4ed8e8;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #a0a0a0;
}

.token.function,
.token.class-name {
    color: #7cc8ff;
}

.token.regex,
.token.important,
.token.variable {
    color: #ff8090;
}

/* Callouts & Link Integrations */
.writeup-content .link-integration {
    display: inline-flex; /* Changed from flex to inline-flex to fit content */
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 24px;
    margin: 0.75rem 0; /* Reduced margins by half */
    border-radius: 100px; /* Pill Shape */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    max-width: 100%; /* Ensure it doesn't overflow on small screens */
    box-sizing: border-box;
}

.writeup-content .link-integration:hover {
    background: rgba(255, 255, 255, 0);
    border-color: var(--accent-color);
    transform: translateX(5px);
}

.writeup-content .link-integration .site-favicon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    /* User request: "toujours en couleur" */
    filter: grayscale(0%);
    transition: filter 0.2s;
}

.writeup-content .link-integration:hover .site-favicon {
    filter: grayscale(0%);
}

.writeup-content .link-integration a {
    color: var(--text-color);
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    text-decoration: none;
    border-bottom: none;
}

.writeup-content .link-integration:hover a {
    color: var(--accent-color);
}

/* Image Encapsulation & Styling */
/* Image Encapsulation & Styling */
.writeup-content figure.image {
    margin: 2rem 0;
    text-align: center;
    background: transparent;
    border: none;
    padding: 0;
    display: block;
    max-width: 100%;
}

.writeup-content img {
    max-width: 100%;
    /* User Request: "hauteur maximale pour les images des writeups est limitée a 50vh" */
    max-height: 50vh;
    width: auto;      /* Maintain aspect ratio */
    height: auto;
    object-fit: contain; /* Ensure integrity */

    display: block;
    margin: 0 auto;
    
    /* Frame on the image itself */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    transition: all 0.3s;
    cursor: zoom-in;
}

.writeup-content img:hover {
    border-color: var(--accent-color);
}

/* Optional: Add a caption style if needed later */
.writeup-content figcaption {
    font-size: 0.8rem;
    color: var(--dim-text);
    margin-top: 0.5rem;
    font-style: italic;
}
/* =============================================
   LIGHTBOX / FOCUS MODE
   ============================================= */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    cursor: zoom-out;
}

.modal-content {
    margin: auto;
    display: block;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    width: fit-content;
    max-width: 95%;
    max-height: 95vh;
}

.modal-image {
    display: block;
    max-width: 100%;
    max-height: 95vh;
    width: auto;
    height: auto;
    border: none;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Cursor on writeup images to indicate they are clickable */
.writeup-content img {
    cursor: zoom-in;
}

/* =============================================
   MOBILE RESPONSIVENESS (Writeups)
   ============================================= */

@media (max-width: 768px) {
    /* Container & Layout */
    .writeups-container {
        width: 100%;
        padding: 0;
    }

    /* Typography */
    .writeups-title {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
    }

    /* Grid - Force 1 column for better readability */
    .writeups-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    /* Writeup Card — touch-optimized */
    .writeup-card {
        padding: 1rem;
        min-height: 48px; /* Min touch target height */
        transition: all 0.15s ease;
    }

    .writeup-card:active {
        transform: scale(0.98);
        border-color: var(--accent-color);
    }

    .writeup-card h3 {
        font-size: 1.2rem;
    }

    .writeup-card p {
        font-size: 0.85rem;
    }

    /* Badges — wrap on small screens */
    .card-badges {
        flex-wrap: wrap;
        gap: 0.4rem;
        padding-top: 0.8rem;
    }

    .badge {
        font-size: 0.65rem;
        padding: 2px 5px;
    }

    /* Code Blocks - Ensure horizontal scroll */
    .code-wrap {
        font-size: 0.72rem;
        padding: 0.8rem;
        margin: 1rem 0;
        border-radius: 0;
        overflow-x: auto;
        max-width: 100%;
        white-space: pre;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Ensure the pre block doesn't push the layout width */
    .page-body pre {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Code window */
    .code-window {
        margin: 1rem 0;
    }

    .writeup-content pre.code {
        padding: 0.8rem;
        font-size: 0.8rem;
    }

    /* Content typography */
    .writeup-content h1 {
        font-size: 1.5rem;
        padding-left: 0.8rem;
        margin-top: 2rem;
    }

    .writeup-content h2 {
        font-size: 1.2rem;
        margin-top: 2rem;
    }

    .writeup-content h3 {
        font-size: 1.1rem;
    }

    .writeup-content p, .writeup-content li {
        font-size: 0.95rem;
        line-height: 1.6;
        text-align: justify;
    }

    /* Images */
    .writeup-content img, .page-body img {
        max-width: 100%;
        max-height: 40vh;
        height: auto;
        border-radius: 0;
    }

    /* Link integrations */
    .writeup-content .link-integration {
        padding: 10px 14px;
        gap: 10px;
        margin: 1rem 0;
    }

    .writeup-content .link-integration a {
        font-size: 0.95rem;
    }
    
    /* Back Link */
    .back-link {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    /* Modal on mobile */
    .modal-nav {
        display: none !important;
    }

    .modal-image {
        max-width: 95%;
        max-height: 80vh;
    }
}

/* =============================================
   LIGHT MODE — Writeup-specific Overrides
   ============================================= */

html[data-theme="light"] .writeup-card {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(30, 28, 48, 0.10);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .writeup-card:hover {
    border-color: rgba(30, 28, 48, 0.28);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.09);
}

html[data-theme="light"] .writeup-card-title {
    color: var(--text-color);
}

html[data-theme="light"] .writeup-date-badge {
    background: rgba(30, 28, 48, 0.05);
    border-color: rgba(30, 28, 48, 0.11);
}

html[data-theme="light"] .platform-htb {
    background: rgba(159, 239, 0, 0.15);
    color: #6aaa00;
    border-color: #9fef00;
}

html[data-theme="light"] .platform-sthack {
    background: rgba(255, 45, 120, 0.15);
    color: #cc1155;
    border-color: #ff2d78;
}

html[data-theme="light"] .platform-mars {
    background: rgba(184, 204, 0, 0.15);
    color: #7a8a00;
    border-color: #b8cc00;
}

html[data-theme="light"] .difficulty-badge {
    color: rgba(30, 28, 48, 0.65);
    background: rgba(30, 28, 48, 0.05);
    border-color: rgba(30, 28, 48, 0.11);
}

html[data-theme="light"] .os-icon {
    filter: brightness(0);
    opacity: 0.6;
}

/* Writeup content page */
html[data-theme="light"] .writeup-content h3 {
    color: #3a3858;
}

html[data-theme="light"] .writeup-content img {
    border-color: rgba(30, 28, 48, 0.1);
}

html[data-theme="light"] .writeup-content img:hover {
    border-color: rgba(30, 28, 48, 0.3);
}

/* Inline code only (not block code inside pre) */
html[data-theme="light"] .writeup-content :not(pre) > code {
    background: rgba(0, 0, 0, 0.06);
    color: #000000;
    border-color: rgba(0, 0, 0, 0.1);
}

/* Full black text */
html[data-theme="light"] .writeup-content h2,
html[data-theme="light"] .writeup-content h3,
html[data-theme="light"] .writeup-content p,
html[data-theme="light"] .writeup-content li,
html[data-theme="light"] .writeup-content a {
    color: #000000;
}

/* Code window in light mode */
html[data-theme="light"] .code-window {
    border-color: rgba(0, 0, 0, 0.18);
}

html[data-theme="light"] .window-header {
    background: rgba(0, 0, 0, 0.06);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .window-title {
    color: rgba(0, 0, 0, 0.4);
}
