/* 4Hats - Main Stylesheet - 2026 Edition */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #030305;
    --bg-secondary: #0a0a0f;
    --bg-card: #0d0d14;
    --gold: #3a0d18;
    --gold-light: #3a0d18;
    --orange: #454852;
    --fire-red: #3a0d18;
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.5);
    --border: rgba(255, 255, 255, 0.06);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 4px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-light);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 20px 0;
    transition: all 0.4s ease;
}

.header.scrolled {
    padding: 12px 0;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 16px;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

.header.scrolled .header-inner {
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: rgba(58, 13, 24, 0.3);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    position: relative;
    z-index: 2;
}

.header-logo {
    width: 45px;
    height: 45px;
    filter: drop-shadow(0 0 8px rgba(58, 13, 24, 0.4));
    transition: filter 0.3s;
    object-fit: contain;
}

.header-brand:hover .header-logo {
    filter: drop-shadow(0 0 15px rgba(138, 37, 63, 0.6));
}

.header-title {
    font-family: 'Audiowide', cursive;
    font-size: 18px;
    background: linear-gradient(135deg, #3a0d18, #3a0d18);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-nav {
    display: none;
    align-items: center;
    gap: 6px;
    list-style: none;
    position: relative;
    z-index: 2;
}

@media (min-width: 900px) {
    .header-nav {
        display: flex;
    }
}

.header-link {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.25s ease;
    position: relative;
}

.header-link:hover,
.header-link.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.header-cta {
    padding: 10px 22px;
    font-size: 13px;
    font-weight: 600;
    color: var(--bg-primary);
    background: linear-gradient(135deg, var(--gold), var(--orange));
    border: none;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.header-cta:hover {
    box-shadow: 0 0 25px rgba(58, 13, 24, 0.4);
    transform: translateY(-2px);
}

.header-menu-btn {
    display: flex;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    position: relative;
    z-index: 2;
}

@media (min-width: 900px) {
    .header-menu-btn {
        display: none;
    }
}

.mobile-menu {
    position: fixed;
    inset: 0;
    background: rgba(3, 3, 5, 0.98);
    z-index: 99;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.mobile-menu.open {
    opacity: 1;
    pointer-events: all;
}

.mobile-menu a {
    font-size: 18px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 12px 24px;
}

/* Page Hero */
.page-hero {
    padding: 160px 0 60px;
    text-align: center;
    position: relative;
}

.page-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    background: var(--gold);
    filter: blur(150px);
    opacity: 0.06;
    pointer-events: none;
}

.page-title {
    font-family: 'Audiowide', cursive;
    font-size: clamp(32px, 6vw, 52px);
    margin-bottom: 12px;
    position: relative;
}

.page-subtitle {
    font-size: 16px;
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

/* Section */
.section {
    padding: 60px 0 100px;
}

.section-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: 14px;
}

.section-header {
    text-align: center;
    margin-bottom: 48px;
}

.section-title {
    font-family: 'Audiowide', cursive;
    font-size: clamp(24px, 4vw, 36px);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--orange));
    color: var(--bg-primary);
    border: none;
}

.btn-primary:hover {
    box-shadow: 0 0 40px rgba(58, 13, 24, 0.35);
    transform: translateY(-3px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.search-input,
.filter-select {
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: rgba(58, 13, 24, 0.3);
}

/* Write-up cards */
.writeups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 28px;
}

.writeup-card {
    display: block;
    position: relative;
    background: linear-gradient(135deg, rgba(10, 10, 20, 0.9), rgba(5, 5, 15, 0.95));
    border: 1px solid transparent;
    border-radius: 24px;
    text-decoration: none;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.writeup-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 24px;
    padding: 2px;
    background: linear-gradient(135deg, transparent, rgba(58, 13, 24, 0.3), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.5s;
}

.writeup-card:hover::before {
    opacity: 1;
}

.writeup-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.5),
        0 0 80px rgba(58, 13, 24, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.writeup-card-inner {
    padding: 32px;
    position: relative;
    z-index: 1;
}

.writeup-card-glow {
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 70% 30%, rgba(58, 13, 24, 0.08), transparent 40%);
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

.writeup-card:hover .writeup-card-glow {
    opacity: 1;
}

.writeup-badge-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.writeup-badge {
    padding: 6px 14px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.writeup-badge.hard {
    background: linear-gradient(135deg, rgba(58, 13, 24, 0.2), rgba(58, 13, 24, 0.1));
    color: #3a0d18;
    border: 1px solid rgba(58, 13, 24, 0.3);
}

.writeup-badge.medium {
    background: linear-gradient(135deg, rgba(255, 160, 0, 0.2), rgba(255, 200, 50, 0.1));
    color: #ffa726;
    border: 1px solid rgba(255, 180, 50, 0.3);
}

.writeup-badge.easy {
    background: linear-gradient(135deg, rgba(50, 200, 100, 0.2), rgba(100, 220, 150, 0.1));
    color: #66bb6a;
    border: 1px solid rgba(100, 200, 120, 0.3);
}

.writeup-badge.category {
    background: linear-gradient(135deg, rgba(58, 13, 24, 0.15), rgba(138, 37, 63, 0.08));
    color: var(--gold);
    border: 1px solid rgba(58, 13, 24, 0.25);
}

.writeup-card-title {
    font-family: 'Audiowide', cursive;
    font-size: 20px;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.3;
    transition: color 0.3s;
}

.writeup-card:hover .writeup-card-title {
    background: linear-gradient(135deg, var(--gold), var(--orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.writeup-card-ctf {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gold);
    margin-bottom: 16px;
    opacity: 0.8;
}

.writeup-card-ctf svg {
    width: 16px;
    height: 16px;
}

.writeup-card-excerpt {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 24px;
}

.writeup-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.writeup-card-date {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
}

.writeup-card-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gold);
    transition: all 0.3s;
}

.writeup-card-link svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s;
}

.writeup-card:hover .writeup-card-link svg {
    transform: translateX(6px);
}

/* ===== PREMIUM RESOURCE CARDS ===== */
.resources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.resource-card {
    display: flex;
    gap: 18px;
    padding: 24px;
    background: linear-gradient(145deg, var(--bg-card), rgba(5, 5, 10, 0.9));
    border: 1px solid var(--border);
    border-radius: 16px;
    text-decoration: none;
    transition: all 0.35s ease;
    position: relative;
    overflow: hidden;
}

.resource-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--gold), var(--orange));
    opacity: 0;
    transition: opacity 0.3s;
}

.resource-card:hover {
    border-color: rgba(58, 13, 24, 0.2);
    transform: translateY(-4px) translateX(4px);
    box-shadow: -8px 8px 30px rgba(0, 0, 0, 0.3);
}

.resource-card:hover::before {
    opacity: 1;
}

.resource-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, rgba(58, 13, 24, 0.15), rgba(138, 37, 63, 0.1));
    border: 1px solid rgba(58, 13, 24, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    flex-shrink: 0;
}

.resource-content {
    flex: 1;
}

.resource-content h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.resource-content p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.5;
}

.resource-content .level {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(58, 13, 24, 0.08);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Category Pills */
.category-pills {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}

.category-pill {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 25px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s ease;
}

.category-pill:hover,
.category-pill.active {
    background: rgba(58, 13, 24, 0.1);
    border-color: rgba(58, 13, 24, 0.3);
    color: var(--gold);
}

/* About */
.about-content {
    max-width: 800px;
    margin: 0 auto;
}

.about-section {
    margin-bottom: 48px;
}

.about-section h2 {
    font-family: 'Audiowide', cursive;
    font-size: 20px;
    margin-bottom: 16px;
    color: var(--gold);
}

.about-section p {
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 12px;
}

.focus-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.focus-item {
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
}

.focus-item h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 6px;
}

.focus-item p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.footer-bottom {
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 48px;
    height: 48px;
    background: rgba(15, 15, 25, 0.9);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s;
    z-index: 50;
}

.back-to-top.visible {
    opacity: 1;
}

.back-to-top:hover {
    border-color: var(--gold);
    color: var(--gold);
    transform: translateY(-4px);
}

/* ===== HERO ===== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    padding: 140px 24px 100px;
}

.hero-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 10;
    max-width: 800px;
}

.hero-title {
    font-family: 'Audiowide', cursive;
    font-size: clamp(36px, 8vw, 72px);
    line-height: 1.15;
    margin-bottom: 24px;
}

.hero-title .highlight {
    background: linear-gradient(135deg, var(--gold), var(--orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 17px;
    color: var(--text-muted);
    margin-bottom: 40px;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.7;
}

.hero-buttons {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

/* CTA */
.cta-section {
    text-align: center;
    padding: 80px 24px;
    position: relative;
}

.cta-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(58, 13, 24, 0.03), transparent 70%);
    pointer-events: none;
}

.cta-title {
    font-family: 'Audiowide', cursive;
    font-size: clamp(22px, 4vw, 32px);
    margin-bottom: 14px;
    position: relative;
}

.cta-text {
    font-size: 15px;
    color: var(--text-muted);
    max-width: 460px;
    margin: 0 auto 28px;
    position: relative;
}

.rankings-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.rankings-toolbar h3 {
    font-family: 'Audiowide', cursive;
    font-size: 20px;
    margin: 0;
}

.rankings-count {
    color: var(--text-muted);
    font-size: 14px;
}

.ranking-link {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--gold);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
}

.ranking-link:hover {
    color: var(--gold-light);
}

/* ===== EXTRA-NARROW PHONE HARDENING ===== */
@media (max-width: 480px) {
    .container {
        padding-left: 14px;
        padding-right: 14px;
    }

    .header-inner {
        gap: 8px;
        padding: 10px;
    }

    .header-brand {
        min-width: 0;
        gap: 8px;
    }

    .header-logo {
        width: 36px;
        height: 36px;
    }

    .header-title {
        font-size: 15px;
        white-space: nowrap;
    }

    .header-cta {
        flex-shrink: 0;
        padding: 9px 13px;
        font-size: 12px;
    }

    .header-menu-btn {
        flex-shrink: 0;
        padding: 9px;
    }
}

@media (max-width: 360px) {
    .header-inner {
        gap: 6px;
        padding: 8px;
    }

    .header-brand {
        gap: 6px;
    }

    .header-logo {
        width: 34px;
        height: 34px;
    }

    .header-title {
        font-size: 14px;
    }

    .header-cta {
        padding: 8px 10px;
        font-size: 11px;
    }

    .header-menu-btn {
        padding: 8px;
    }
}

/* ===== MOBILE CONTENT GRID SAFETY ===== */
@media (max-width: 700px) {
    .writeups-grid,
    .resources-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .writeup-card-inner {
        padding: 24px 20px;
    }

    .resource-card {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .section {
        padding-top: 52px;
        padding-bottom: 72px;
    }

    .page-hero {
        padding-top: 132px;
        padding-bottom: 46px;
    }

    .filter-bar {
        gap: 10px;
    }

    .search-input,
    .filter-select {
        min-width: 0;
        max-width: 100%;
    }

    .search-input {
        flex-basis: 100%;
    }

    .writeup-content-wrapper {
        padding-top: 42px;
        padding-bottom: 72px;
    }

    .writeup-content {
        font-size: 15px;
    }

    .writeup-content pre {
        padding: 16px;
        font-size: 13px;
    }
}
