:root {
    --bg: #0d0d0d;  /* was #1a1a1a */
    --card-bg: #141414;  /* was #222222 */
    --text-main: #ffffff;
    --text-muted: #888888;
    --accent: #ff4d4d;
    --border: #1f1f1f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background-color: var(--bg);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

nav { display: flex; justify-content: center; gap: 3rem; padding: 2rem; border-bottom: 1px solid var(--border); }
nav a { color: var(--text-muted); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 2px; cursor: pointer; transition: 0.3s; }
nav a:hover, nav a.active { color: var(--accent); }

.container {
    max-width: 900px;
    margin: 4rem auto;
    padding: 0 2rem;
    flex: 1;
    width: 100%;
}

.view { display: none; }
.view.active-view { display: flex; flex-direction: column; gap: 1.5rem; animation: fadeIn 0.5s; }

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

.header { text-align: center; margin-bottom: 2rem; }
.header h1 { font-size: 3rem; font-weight: 600; letter-spacing: -1px; }
.header p { color: var(--text-muted); margin-top: 0.5rem; }

#home .header {
    position: relative;
    padding: 3rem 2rem;
    margin-bottom: 0;
    overflow: hidden;
}

#home .header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, #3a3a3a 1.5px, transparent 1.5px);  /* brighter + slightly bigger dot */
    background-size: 24px 24px;  /* tighter grid */
    z-index: 0;
    pointer-events: none;
}

#home .header::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 50% 50%, transparent 40%, var(--bg) 100%);
    z-index: 1;
    pointer-events: none;
}

#home .header h1,
#home .header p {
    position: relative;
    z-index: 2;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 4px;
    transition: 0.3s;
    color: inherit;
    display: block;
    cursor: pointer;
}
.card:hover { border-color: var(--accent); }
.card h3 { margin-bottom: 0.5rem; font-weight: 600; }
.card p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }

.card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.badge {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.18em 0.55em;
    border-radius: 3px;
    border: 1px solid;
}
.badge-HTB   { color: #9fef00; border-color: #9fef00; background: rgba(159,239,0,0.08); }
.badge-THM   { color: #ff6b6b; border-color: #ff6b6b; background: rgba(255,107,107,0.08); }
.badge-PG    { color: #7b9cff; border-color: #7b9cff; background: rgba(123,156,255,0.08); }
.badge-VH    { color: #cc88ff; border-color: #cc88ff; background: rgba(204,136,255,0.08); }
.badge-OTHER { color: #ffcc55; border-color: #ffcc55; background: rgba(255,204,85,0.08); }

.diff {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.18em 0.55em;
    border-radius: 3px;
    border: 1px solid;
}
.diff-Easy   { color: #9fef00; border-color: #9fef00; background: rgba(159,239,0,0.08); }
.diff-Medium { color: #ffcc00; border-color: #ffcc00; background: rgba(255,204,0,0.08); }
.diff-Hard   { color: #ff4d4d; border-color: #ff4d4d; background: rgba(255,77,77,0.08); }
.diff-Insane { color: #cc88ff; border-color: #cc88ff; background: rgba(204,136,255,0.08); }

.tag {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.18em 0.55em;
    border-radius: 3px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
}

.post-view { display: none; flex-direction: column; gap: 1.5rem; animation: fadeIn 0.5s; }
.post-view.active-view { display: flex; }

.back-btn {
    background: none; border: none;
    color: var(--text-muted); font-family: 'Inter', sans-serif;
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 2px;
    cursor: pointer; padding: 0; transition: 0.3s; text-align: left;
}
.back-btn:hover { color: var(--accent); }

.post-content {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3rem;
    line-height: 1.8;
}
.post-content h1 { font-size: 2rem; font-weight: 600; margin-bottom: 1.5rem; }
.post-content h2 { font-size: 1.4rem; font-weight: 600; margin: 2rem 0 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.post-content h3 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.75rem; }
.post-content p  { color: var(--text-muted); margin-bottom: 1rem; }
.post-content a  { color: var(--accent); text-decoration: none; }
.post-content a:hover { text-decoration: underline; }
.post-content ul, .post-content ol { color: var(--text-muted); margin: 0.75rem 0 1rem 1.5rem; }
.post-content li { margin-bottom: 0.4rem; }
.post-content code { background: #2a2a2a; border: 1px solid var(--border); border-radius: 3px; padding: 0.15em 0.4em; font-size: 0.85em; font-family: 'Courier New', monospace; color: #f0f0f0; }

/* Code blocks wrapper to lock the copy button layout completely */
.code-wrapper {
    position: relative;
    margin: 1rem 0;
    width: 100%;
}

.post-content pre { 
    background: #151515; 
    border: 1px solid var(--border); 
    border-radius: 4px; 
    padding: 1.5rem; 
    overflow-x: auto; 
    margin: 0; /* Margins handled entirely by .code-wrapper */
}
.post-content pre code { background: none; border: none; padding: 0; font-size: 0.9rem; }
.post-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1rem 0; color: var(--text-muted); font-style: italic; }
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.post-content strong { color: var(--text-main); }
.post-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.post-content td { 
    color: var(--text-muted); 
    padding: 0.6rem 1rem; 
    text-align: left;
}
.post-content th { background: #2a2a2a; color: var(--text-main); }
.post-content td strong { 
    color: var(--text-main);
    font-weight: 600;
}

/* Base Image Formatting */
.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem 0;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: zoom-in;
    transition: border-color 0.2s ease;
}
.post-content img:hover {
    border-color: var(--accent);
}

/* Code block dynamic element targets the non-scrolling wrapper */
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 77, 77, 0.15);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.35rem 0.7rem;
    border-radius: 3px;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}

/* Desktop hover configuration on outer wrapper */
.code-wrapper:hover .copy-btn {
    opacity: 1;
    pointer-events: auto;
}
.copy-btn:hover {
    background: rgba(255, 77, 77, 0.3);
    transform: scale(1.03);
}
.copy-btn:active {
    transform: scale(0.98);
}
.copy-btn.copied {
    background: rgba(159, 239, 0, 0.2);
    border-color: #9fef00;
    color: #9fef00;
}

/* Lightbox Modal System Layout */
.lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    cursor: zoom-out;
}
.lightbox-modal.active {
    opacity: 1;
    pointer-events: auto;
}
.lightbox-modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 4px;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}
.lightbox-modal.active img {
    transform: scale(1);
}

/* Toast notification */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(159, 239, 0, 0.95);
    color: #1a1a1a;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideInUp 0.3s ease;
    z-index: 1000;
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideOutDown {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}
.toast-notification.fade-out {
    animation: slideOutDown 0.3s ease forwards;
}

.loading { color: var(--text-muted); font-size: 0.9rem; padding: 2rem 0; }
footer { text-align: center; padding: 2rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: auto; }
.socials { font-size: 1.2rem; display: flex; justify-content: center; gap: 2rem; }
.socials a { color: var(--text-muted); transition: 0.3s; }
.socials a:hover { color: var(--accent); }

/* Responsive Adjustments across target devices */
@media (max-width: 1024px) {
    /* Touch interfaces don't provide native hovers; ensure button stays tracking and visible */
    .copy-btn {
        opacity: 1;
        pointer-events: auto;
        background: rgba(255, 77, 77, 0.25);
        top: 0.4rem;
        right: 0.4rem;
    }
}

@media (max-width: 768px) {
    .copy-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.6rem;
    }
    .post-content {
        padding: 1.5rem;
    }
    .toast-notification {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .copy-btn {
        padding: 0.35rem 0.7rem;
        font-size: 0.55rem;
        top: 0.25rem;
        right: 0.25rem;
    }
    .post-content pre {
        padding: 1rem;
        padding-top: 2.5rem; /* Forces content shift downward so copy elements don't overlay top string code lines */
    }
    .post-content {
        padding: 1rem;
        font-size: 0.95rem;
    }
    .toast-notification {
        bottom: 1rem;
        right: 0.5rem;
        left: 0.5rem;
        padding: 0.8rem 1rem;
        font-size: 0.8rem;
    }
}
