/* =====================================================================
   Home page layout (glass theme itself is in style.css)
   ===================================================================== */

/* ---------- Layout ---------- */
body.home .container { max-width: 1440px; margin-top: 2.5rem; }

.home-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1.75rem;
    align-items: start;
}

.home-main { display: flex; flex-direction: column; gap: 1.75rem; min-width: 0; }

/* ---------- Hero ---------- */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: center;
    padding: 3rem 2.75rem;
}

.hero-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #7df9ff;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(0, 243, 255, 0.08);
    border: 1px solid rgba(0, 243, 255, 0.25);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    box-shadow: 0 0 10px var(--success-color);
    animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }

.hero h1 {
    font-family: var(--font-heading);
    font-size: clamp(1.9rem, 3.3vw, 3rem);
    overflow-wrap: anywhere;
    line-height: 1.05;
    margin: 1.1rem 0 1rem;
    background: linear-gradient(100deg, #ffffff 0%, #7df9ff 40%, #c4a4ff 75%, #ffffff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 22px rgba(0, 243, 255, 0.25));
}

@keyframes shine { to { background-position: 200% center; } }

.hero p.lead { color: #b9c6cf; font-size: 1.1rem; line-height: 1.7; max-width: 560px; margin: 0 0 1.75rem; }
.hero p.lead code { color: var(--success-color); background: rgba(0, 255, 65, 0.08); padding: 0.1em 0.4em; border-radius: 6px; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.9rem; }

.glass-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.95rem 1.5rem;
    border-radius: 14px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.88rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-decoration: none;
    color: #e8fdff;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}

.glass-btn:hover { transform: translateY(-2px); border-color: rgba(0, 243, 255, 0.6); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 26px rgba(0, 243, 255, 0.25); }
.glass-btn.primary {
    color: #001014;
    border-color: transparent;
    background: linear-gradient(135deg, #00f3ff, #6ef7c8);
    box-shadow: 0 10px 30px rgba(0, 243, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.glass-btn.primary:hover { box-shadow: 0 14px 40px rgba(0, 243, 255, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.glass-btn svg { width: 18px; height: 18px; flex: none; }

.hero-side { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.stat-chips { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.stat-chip { flex: 1 1 0; }
.stat-chip {
    display: flex;
    flex-direction: column;
    padding: 0.6rem 1rem;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 108px;
}
.stat-chip b { font-family: var(--font-heading); font-size: 1.35rem; color: #fff; }
.stat-chip span { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 1.5px; text-transform: uppercase; color: #8aa0aa; }

/* Terminal window */
.terminal {
    border-radius: 16px;
    background: rgba(2, 8, 12, 0.72);
    border: 1px solid rgba(0, 243, 255, 0.22);
    box-shadow: 0 0 40px rgba(0, 243, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: 0.86rem;
}
.terminal-bar { display: flex; align-items: center; gap: 6px; padding: 0.6rem 0.9rem; background: rgba(255, 255, 255, 0.04); border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.terminal-bar i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.terminal-bar i:nth-child(1) { background: #ff5f57; } .terminal-bar i:nth-child(2) { background: #febc2e; } .terminal-bar i:nth-child(3) { background: #28c840; }
.terminal-bar span { margin-left: auto; color: #5f7680; font-size: 0.72rem; }
/* Fixed height: output scrolls inside the window so the layout never moves while it types.
   contain: strict keeps its constant updates from invalidating the rest of the page. */
.terminal pre { contain: strict; margin: 0; padding: 1rem 1.1rem 1.2rem; height: 230px; overflow: hidden; white-space: pre-wrap; word-break: break-all; color: #9fe9ff; line-height: 1.65; }
.terminal .p { color: var(--success-color); }
.terminal .o { color: #7d8f96; }
.terminal .f { color: #ffe066; text-shadow: 0 0 12px rgba(255, 224, 102, 0.6); font-weight: 700; }
.cursor { display: inline-block; width: 0.6em; height: 1.1em; vertical-align: text-bottom; background: #7df9ff; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Rotating highlight ---------- */
.ticker {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.4rem;
    border-radius: 16px;
    font-family: var(--font-mono);
}
.ticker-icon {
    flex: none;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    font-size: 1.25rem;
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid rgba(0, 243, 255, 0.3);
    box-shadow: 0 0 18px rgba(0, 243, 255, 0.2);
}
.ticker.firstblood .ticker-icon { background: rgba(255, 0, 60, 0.12); border-color: rgba(255, 0, 60, 0.45); box-shadow: 0 0 18px rgba(255, 0, 60, 0.3); }
.ticker-body { display: flex; flex-direction: column; min-width: 0; transition: opacity 0.4s, transform 0.4s; }
.ticker-body.fade { opacity: 0; transform: translateY(6px); }
.ticker-label { color: #7f97a1; font-size: 0.7rem; letter-spacing: 2px; text-transform: uppercase; }
.ticker-value { color: #fff; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker-value .who { color: #6effa8; font-weight: 700; }
.ticker.firstblood .ticker-value .who { color: #ff5c7c; }
.ticker-value a { color: #7df9ff; text-decoration: none; }
.ticker-value a:hover { text-decoration: underline; }

/* ---------- Section panels ---------- */
.panel { padding: 1.75rem 1.9rem 2rem; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem 1rem; margin-bottom: 1.4rem; }
.panel-head h2 { margin: 0; font-family: var(--font-heading); font-size: 1.25rem; letter-spacing: 1px; color: #fff; display: flex; align-items: center; gap: 0.6rem; }
.panel-head h2 .pip { width: 10px; height: 10px; border-radius: 3px; background: linear-gradient(135deg, #00f3ff, #a855f7); box-shadow: 0 0 12px rgba(0, 243, 255, 0.6); }
.pill-link {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-decoration: none;
    color: #7df9ff;
    padding: 0.5rem 0.95rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 243, 255, 0.3);
    background: rgba(0, 243, 255, 0.06);
    transition: background 0.2s, box-shadow 0.2s;
}
.pill-link:hover { background: rgba(0, 243, 255, 0.14); box-shadow: 0 0 18px rgba(0, 243, 255, 0.25); }

.empty-glass { text-align: center; color: #8aa0aa; padding: 2.2rem 1rem; border: 1px dashed rgba(255, 255, 255, 0.14); border-radius: 16px; }

/* ---------- How it works ---------- */
.steps { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.1rem; }

/* light trail connecting the steps */
.steps::before {
    content: '';
    position: absolute;
    top: 44px;
    left: 9%;
    right: 9%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(0, 243, 255, 0.55), rgba(168, 85, 247, 0.55), rgba(0, 255, 136, 0.55), transparent);
    box-shadow: 0 0 12px rgba(0, 243, 255, 0.5);
}

.step {
    position: relative;
    padding: 1.25rem 1.15rem 1.35rem;
    border-radius: 18px;
    /* Nearly opaque so the connecting light trail only shows in the gaps between steps */
    background: linear-gradient(160deg, rgba(22, 30, 38, 0.96), rgba(9, 13, 17, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
    transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.step:hover { transform: translateY(-4px); border-color: var(--step-color); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 14px 36px color-mix(in srgb, var(--step-color) 25%, transparent); }

.step-icon {
    position: relative;
    z-index: 1;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: var(--step-color);
    background: rgba(5, 10, 14, 0.85);
    border: 1px solid color-mix(in srgb, var(--step-color) 55%, transparent);
    box-shadow: 0 0 22px color-mix(in srgb, var(--step-color) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    margin-bottom: 1rem;
}
.step-icon svg { width: 28px; height: 28px; }


.step h3 { margin: 0 0 0.4rem; font-size: 1.05rem; color: #fff; font-family: var(--font-body); }
.step p { margin: 0; color: #a3b3ba; font-size: 0.9rem; line-height: 1.55; }
.step code { color: var(--success-color); background: rgba(0, 255, 65, 0.08); padding: 0.05em 0.35em; border-radius: 5px; font-size: 0.85em; }

.steps-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; padding: 1.1rem 1.3rem; border-radius: 16px; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(255, 255, 255, 0.07); }
.steps-cta span { color: #c9d6dc; }

/* ---------- Top 20 sidebar ---------- */
.leader { position: sticky; top: 84px; padding: 1.5rem 1.25rem 1.4rem; }
.leader .panel-head { margin-bottom: 1rem; }
.live-tag { display: inline-flex; align-items: center; gap: 0.45rem; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 2px; color: #6effa8; }

.leader-view {
    position: relative;
    height: 560px;
    overflow: hidden;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    mask-image: linear-gradient(transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);
}
.leader-view.fits { height: auto; mask-image: none; }
.leader-track { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.leader-view:not(.fits) { contain: strict; }
.leader-view.fits .leader-track { position: static; }

.leader-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    margin: 0.35rem 0.4rem;
    border-radius: 12px;
    text-decoration: none;
    color: #dbe7ec;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}
.leader-row:hover { background: rgba(0, 243, 255, 0.07); border-color: rgba(0, 243, 255, 0.25); }
.leader-rank {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #8aa0aa;
    background: rgba(255, 255, 255, 0.05);
}
.leader-row.r1 .leader-rank { color: #1a1300; background: linear-gradient(135deg, #ffe680, #ffb300); box-shadow: 0 0 14px rgba(255, 196, 0, 0.55); }
.leader-row.r2 .leader-rank { color: #111; background: linear-gradient(135deg, #f4f7fa, #9aa7b3); box-shadow: 0 0 12px rgba(200, 210, 220, 0.4); }
.leader-row.r3 .leader-rank { color: #1a0a00; background: linear-gradient(135deg, #f0b07a, #b4652a); box-shadow: 0 0 12px rgba(205, 127, 50, 0.45); }
.leader-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-bar { grid-column: 2 / 4; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.06); overflow: hidden; margin-top: -0.15rem; }
.leader-bar i { display: block; height: 100%; background: linear-gradient(90deg, #00f3ff, #a855f7); box-shadow: 0 0 8px rgba(0, 243, 255, 0.6); }
.leader-score { color: #6effa8; font-weight: 700; }
.leader-empty { color: #7f97a1; text-align: center; padding: 2rem 1rem; font-family: var(--font-mono); font-size: 0.85rem; }
.leader .glass-btn { width: 100%; justify-content: center; margin-top: 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .hero { grid-template-columns: 1fr; }
    .terminal { display: none; }
    .hero-side { margin-top: -0.5rem; }
}

@media (max-width: 1000px) {
    .home-layout { grid-template-columns: 1fr; }
    .leader { position: static; }
    .leader-view { height: 420px; }
    .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .steps::before { display: none; }
}

@media (max-width: 560px) {
    body.home .container { padding: 0 1rem; margin-top: 1.25rem; }
    .hero { padding: 2rem 1.3rem; }
    .panel { padding: 1.4rem 1.1rem 1.5rem; }
    .steps { grid-template-columns: 1fr; }
    .ticker-value { white-space: normal; }
}

/* Respect "reduce motion": no drifting, shimmering or auto-scrolling. */
@media (prefers-reduced-motion: reduce) {
    .live-dot, .cursor { animation: none; }
}

/* ---------- One-screen layout on desktop ----------
   Everything (hero, highlight, new challenges, how it works, top 20) fits in one viewport on
   large screens: tighter spacing, one row of tiles, compact steps, and a Top 20 column that
   stretches to the height of the main column. */
.step p a { color: #7df9ff; text-decoration: none; border-bottom: 1px dashed rgba(125, 249, 255, 0.5); }
.step p a:hover { color: #fff; border-bottom-color: #fff; }

@media (min-width: 1500px) {
    body.home .container { max-width: 1840px; }
    /* Up to 6 newest challenges in a single row on wide screens */
    body.home .tile-grid { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; gap: 0.75rem !important; }
    body.home .challenge-tile { padding: 0.85rem 0.9rem !important; }
    body.home .challenge-tile h3 { font-size: 0.95rem; }
    body.home .challenge-tile .tile-summary { font-size: 0.82rem; }
    body.home .tile-tags .tag { font-size: 0.6rem; padding: 1px 7px; }
    /* Badges stay on one line so every tile in the row has the same height;
       long category names are shortened with "…" (full name is on the challenge page). */
    body.home .tile-tags { flex-wrap: nowrap; overflow: hidden; }
    body.home .tile-tags .tag { flex: none; white-space: nowrap; }
    body.home .tile-tags .tag:first-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
}

@media (min-width: 1001px) {
    body.home .container { margin-top: 0.9rem; margin-bottom: 0.25rem; }
    body.home .site-footer { padding: 0.45rem 1rem 0.6rem !important; }
    .home-layout { align-items: stretch; gap: 1.25rem; }
    .home-main { gap: 1rem; }

    .hero { padding: 1.4rem 2rem; gap: 1.75rem; }
    .hero h1 { font-size: clamp(1.8rem, 2.4vw, 2.6rem); margin: 0.6rem 0 0.5rem; }
    .hero p.lead { font-size: 1rem; line-height: 1.6; margin-bottom: 1.1rem; }
    .glass-btn { padding: 0.75rem 1.2rem; font-size: 0.8rem; }
    .stat-chips { gap: 0.6rem; }
    .stat-chip { padding: 0.45rem 0.85rem; min-width: 96px; }
    .stat-chip b { font-size: 1.15rem; }
    .terminal { font-size: 0.8rem; }
    .terminal pre { height: 150px; padding: 0.7rem 1rem; line-height: 1.55; }

    .ticker { padding: 0.5rem 1.1rem; }
    .ticker-icon { width: 36px; height: 36px; font-size: 1.05rem; }

    .panel { padding: 0.95rem 1.4rem 1.05rem; }
    .panel-head { margin-bottom: 0.7rem; }
    .panel-head h2 { font-size: 1.1rem; }

    body.home .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.9rem; }
    body.home .challenge-tile { min-height: 0; padding: 1rem; gap: 0.45rem; }
    body.home .challenge-tile .tile-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .empty-glass { padding: 1.4rem 1rem; }

    .steps { gap: 0.9rem; }
    .steps::before { top: 50%; }
    .step { padding: 0.75rem 0.95rem; display: flex; align-items: center; gap: 0.85rem; }
    .step-icon { flex: none; width: 44px; height: 44px; border-radius: 13px; margin-bottom: 0; }
    .step-text { min-width: 0; padding-right: 1.6rem; }
    .step-icon svg { width: 22px; height: 22px; }
    .step h3 { font-size: 0.98rem; margin-bottom: 0.25rem; }
    .step p { font-size: 0.86rem; }

    /* Top 20 fills the column height; the list scrolls inside it */
    .leader { position: static; display: flex; flex-direction: column; padding: 1.2rem 1.1rem 1.1rem; }
    .leader-view { flex: 1 1 auto; height: auto; min-height: 260px; }
    .leader-view.fits { flex: 0 0 auto; }
    .leader .glass-btn { margin-top: 0.9rem; }
}

/* =====================================================================
   Calm palette for the home page (overrides above): plain title, solid
   accent, uniform steps, single-colour Top 20 bars.
   ===================================================================== */
.hero h1 {
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    color: #f2f7f9;
    filter: none;
}
.hero p.lead { color: #b9c6cf; }
.hero p.lead strong { color: #fff; font-size: 1.15em; }
.hero-kicker { color: #9fb3bb; background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.12); }

.glass-btn.primary { background: #00dce8; box-shadow: none; }
.glass-btn.primary:hover { background: #33ecf5; box-shadow: 0 0 16px rgba(0, 243, 255, 0.3); }

.panel-head h2 .pip { background: #00dce8; box-shadow: none; }

.ticker-icon,
.ticker.firstblood .ticker-icon { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.12); box-shadow: none; }
.ticker-value .who,
.ticker.firstblood .ticker-value .who { color: #7df9ff; }

/* How it works: identical cards, number as a small label in the text flow (no overlap when resizing) */
.steps::before { display: none; }
.step:hover { border-color: rgba(0, 243, 255, 0.35); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14); transform: translateY(-2px); }
.step-icon {
    color: #7df9ff;
    background: rgba(0, 243, 255, 0.06);
    border: 1px solid rgba(0, 243, 255, 0.25);
    box-shadow: none;
}
.step-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #7f97a1;
    margin-bottom: 0.15rem;
}
.step-text { padding-right: 0 !important; min-width: 0; }
.step h3 { margin-top: 0; }

/* Top 20: single-colour bars, softer medals */
.leader-bar i { background: rgba(0, 220, 232, 0.65); box-shadow: none; }
.leader-row.r1 .leader-rank, .leader-row.r2 .leader-rank, .leader-row.r3 .leader-rank { box-shadow: none; }
.step p { overflow-wrap: anywhere; }
@media (min-width: 1001px) {
    .step { padding: 0.65rem 0.9rem; }
    .step-label { margin-bottom: 0.05rem; }
    .home-main { gap: 0.9rem; }
}
/* Medium widths: 2 x 2 steps so each card has room for its text */
@media (min-width: 1001px) and (max-width: 1399px) {
    .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Badges on one line at every desktop width so tiles in a row stay the same height */
@media (min-width: 1001px) {
    body.home .tile-tags { flex-wrap: nowrap; overflow: hidden; }
    body.home .tile-tags .tag { flex: none; white-space: nowrap; }
    body.home .tile-tags .tag:first-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
}
/* Home tiles: titles clamp to 2 lines with a trailing "…" when they overrun, so a long title
   (e.g. "Make Like a Tree and 'Git' Outta Here") reads cleanly instead of clipping mid-letter. The
   ellipsis must live on the <span> (the text node); text-overflow on the flex <h3> has nothing to clip.
   The h3's fixed height keeps every tile's row height constant whether the title is 1 or 2 lines. */
@media (min-width: 1001px) {
    body.home .challenge-tile h3 { white-space: normal; overflow: hidden; }
    body.home .challenge-tile h3 > span {
        display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
        white-space: normal; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
    }
}

/* Rotating highlight: centred in its bar */
.ticker { justify-content: center; text-align: center; }
.ticker-body { align-items: center; max-width: calc(100% - 60px); }

/* Top 10 normally fits without scrolling; keep the button at the bottom of the column */
@media (min-width: 1001px) {
    .leader-view.fits { flex: 1 1 auto; }
}
/* The section is already "New Challenges", so the NEW badge is redundant on home tiles
   (and dropping it leaves room for category + difficulty + PREMIUM). */
body.home .home-main .challenge-tile .tag-new { display: none; }
