/* ============================================================
   Doom Clone — Hub. Layout based on the Cloud-Shooter prototype:
   centered vertical flow, framework nodes neutral, content nodes
   coloured, add-button small with a hand-drawn arrow hint while
   the timeline is empty. Visual variables retuned to the editor's
   warm beige palette so it feels part of the same product.
   ============================================================ */

:root {
    /* Dark game-launcher theme — deep navy base with warm accent so
     * cartridges read as glowing artefacts on the page rather than
     * folder thumbnails. The accent stays in the warm-orange family
     * so it matches the engine's HUD palette. */
    --bg:           #0d1018;
    --paper:        #14181f;
    --surface:      #1a1f29;
    --panel:        #1a1f29;
    --surface-2:    #232936;
    --surface-3:    #2c3340;
    --border:       #2a3140;
    --border-strong:#3d4658;
    --line:         #2a3140;
    --text:         #e8e9eb;
    --text-mid:     #a8acb5;
    --text-sec:     #a8acb5;
    --text-dim:     #707682;
    --accent:       #ff8a3a;
    --accent-faint: #2b1f15;
    --accent-light: #ffb070;
    --accent-fg:    #ffd0a3;
    --green:        #4dd075;
    --green-faint:  #18301f;
    --orange:       #ff8a3a;
    --red:          #ff4d4d;
    --red-bright:   #ff6060;
    --preview-bg:   #14181f;

    --radius-sm:  6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45),
                 0 2px 4px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55),
                 0 4px 8px rgba(0, 0, 0, 0.30);
}

/* Subtle vignette + scan-line texture on the body so the dark surface
 * never feels flat. CSS-only — no extra image fetch. */
html, body { background: var(--bg); }
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(255, 138, 58, 0.08), transparent 55%),
        radial-gradient(ellipse at 50% 100%, rgba(80, 80, 200, 0.05), transparent 60%),
        repeating-linear-gradient(0deg,
            rgba(255, 255, 255, 0.012) 0px,
            rgba(255, 255, 255, 0.012) 1px,
            transparent 1px, transparent 3px);
    z-index: 0;
}
.hub-page { position: relative; z-index: 1; }
.hub-header h1 {
    font-weight: 900 !important;
    letter-spacing: 4px !important;
    text-transform: uppercase;
    color: var(--text);
    text-shadow: 0 0 20px rgba(255, 138, 58, 0.18);
}
.hub-subtitle {
    color: var(--text-dim) !important;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 11px !important;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text",
          "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
button, input { font: inherit; color: inherit; }

/* ============================================================
   PAGE LAYOUT
   ============================================================ */

.hub-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding-bottom: 0;
}

.hub-header {
    text-align: center;
    padding: 48px 20px 12px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}
.hub-header h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 4px;
    text-transform: uppercase;
}
.hub-header .hub-subtitle {
    font-size: 11px;
    color: var(--text-sec);
    letter-spacing: 3px;
    margin-top: 6px;
    text-transform: uppercase;
}

.hub-user-badge {
    position: absolute;
    top: 20px; right: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font: 600 12px/1 inherit;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, color 0.15s;
}
.hub-user-badge:hover {
    border-color: var(--accent);
    color: var(--accent-fg);
}

/* ============================================================
   VIEW TOGGLE
   ============================================================ */

.hub-view { display: none; width: 100%; }
.hub-view.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#hub-view-timeline.active {
    justify-content: center;
    min-height: 0;
    flex: 1;
    padding-bottom: 20px;
}

/* ============================================================
   CARTRIDGE GRID
   ============================================================ */

.hub-cart-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
    margin-top: 32px;
    padding: 0 20px;
}
@media (max-width: 640px) {
    .hub-cart-grid { gap: 16px; padding: 0 12px; }
}

.hub-cart {
    width: clamp(150px, 42vw, 220px);
    background: linear-gradient(180deg, var(--surface) 0%, var(--paper) 100%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    position: relative;
}
.hub-cart::after {
    /* Subtle top-edge highlight so the card reads as a slightly raised
     * tile, like a backlit cartridge. */
    content: '';
    position: absolute; left: 0; right: 0; top: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
    pointer-events: none;
}
.hub-cart:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg),
                0 0 0 1px var(--accent),
                0 0 24px rgba(255, 138, 58, 0.25);
    border-color: var(--accent);
}

.hub-cart-art {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--preview-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.hub-cart-art img {
    width: 100%; height: 100%; object-fit: cover;
}

.hub-cart-ph {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    overflow: hidden;
    animation: cart-ph-pulse 2.4s ease-in-out infinite;
}
.hub-cart-ph::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        110deg,
        transparent 30%,
        rgba(255,255,255,0.55) 50%,
        transparent 70%);
    background-size: 220% 100%;
    animation: cart-ph-shimmer 2.8s linear infinite;
    pointer-events: none;
}
.hub-cart-ph svg {
    position: relative;
    z-index: 1;
    opacity: 0.55;
}
@keyframes cart-ph-pulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 0.9; }
}
@keyframes cart-ph-shimmer {
    0%   { background-position: 220% 0; }
    100% { background-position: -120% 0; }
}

.hub-cart-del {
    position: absolute;
    top: 8px; right: 8px;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(28, 24, 16, 0.55);
    border: 0; border-radius: 50%;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.1s;
}
.hub-cart:hover .hub-cart-del { opacity: 1; }
.hub-cart-del:hover { background: var(--red); }

.hub-cart-body {
    padding: 14px 16px 12px;
}
.hub-cart-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hub-cart-meta {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* "Neues Game"-Karte */
.hub-cart-new {
    border-style: dashed;
    background: transparent;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    min-height: clamp(160px, 36vw, 220px);
    aspect-ratio: 4 / 3;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.hub-cart-new:hover {
    border-color: var(--accent);
    background: var(--accent-faint);
    transform: translateY(-4px);
}
.hub-cart-new svg {
    color: var(--text-dim);
    transition: color 0.15s;
}
.hub-cart-new:hover svg { color: var(--accent); }
.hub-cart-new-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    margin-top: 8px;
    letter-spacing: 0.5px;
    transition: color 0.15s;
}
.hub-cart-new:hover .hub-cart-new-label { color: var(--accent); }

/* ============================================================
   TIMELINE VIEW
   ============================================================ */

/* Title area — cover, title, subtitle stacked */
.hub-tl-title-area {
    text-align: center;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Cover — click to upload */
.hub-tl-cover {
    width: 160px;
    height: 120px;
    border-radius: 14px;
    border: 2px solid var(--border);
    background: var(--preview-bg);
    color: var(--text-dim);
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, transform 0.15s;
    flex-shrink: 0;
}
.hub-tl-cover:hover {
    border-color: var(--accent);
    transform: scale(1.03);
}
.hub-tl-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* Cover placeholder shimmer (mirrors cart) */
.hub-tl-cover.is-empty {
    position: relative;
    overflow: hidden;
    animation: cart-ph-pulse 2.4s ease-in-out infinite;
}
.hub-tl-cover.is-empty::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        110deg,
        transparent 30%,
        rgba(255,255,255,0.55) 50%,
        transparent 70%);
    background-size: 220% 100%;
    animation: cart-ph-shimmer 2.8s linear infinite;
    pointer-events: none;
}
.hub-tl-cover svg {
    position: relative;
    z-index: 1;
    opacity: 0.55;
}

/* Inline-editable title */
.hub-tl-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 3px;
    margin: 0;
    cursor: text;
    display: inline-block;
    min-width: 80px;
    padding: 2px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.hub-tl-title:hover { border-color: var(--border); }
.hub-tl-title:focus {
    border-color: var(--accent);
    background: var(--panel);
}
.hub-tl-title:empty::before {
    content: attr(data-placeholder);
    color: var(--text-dim);
    opacity: 0.6;
}

/* Inline-editable subtitle */
.hub-tl-subtitle {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    display: inline-block;
    min-width: 160px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    outline: none;
    cursor: text;
    transition: border-color 0.15s, background 0.15s;
}
.hub-tl-subtitle:hover { border-color: var(--border); }
.hub-tl-subtitle:focus {
    border-color: var(--accent);
    background: var(--panel);
    color: var(--text);
}
.hub-tl-subtitle:empty::before {
    content: attr(data-placeholder);
    opacity: 0.6;
}

/* Track */
.hub-tl-track {
    width: 100%;
    padding: 48px 40px 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    overflow: visible;
}

/* Connecting line */
.hub-track-line {
    flex-shrink: 0;
    width: 64px;
    height: 3px;
    background: var(--border);
}

/* Scene node */
.hub-track-node {
    flex-shrink: 0;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--panel);
    border: 3px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: var(--shadow-sm);
    color: var(--text-mid);
}
.hub-track-node svg { width: 28px; height: 28px; }
.hub-track-node:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

/* Fixed framework nodes — neutral, recede */
.hub-track-node[data-type="hud"],
.hub-track-node[data-type="menu"] {
    border-color: var(--text-sec);
    color: var(--text-sec);
    opacity: 0.7;
}

/* User-created content — coloured */
.hub-track-node[data-type="level"] {
    border-color: var(--green);
    color: var(--green);
    opacity: 1;
}

.hub-node-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 12px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-dim);
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    pointer-events: none;
    opacity: 0.45;
    transition: opacity 0.15s, color 0.15s;
}
.hub-track-node:hover .hub-node-label,
.hub-track-add:hover .hub-node-label {
    opacity: 1;
    color: var(--text);
}

.hub-node-del {
    position: absolute;
    top: -8px; right: -8px;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    border: 2px solid var(--panel);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.1s;
}
.hub-node-del:hover { background: var(--red-bright); }
.hub-track-node:hover .hub-node-del { display: flex; }

/* Add button — small, dashed */
.hub-track-add {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    position: relative;
}
.hub-track-add:hover {
    border-color: var(--accent);
    color: var(--accent-fg);
    background: var(--accent-faint);
    transform: scale(1.1);
}

/* Hand-drawn arrow hint when no level exists yet */
.hub-add-hint {
    position: absolute;
    top: 100%;
    right: -60px;
    margin-top: 8px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    animation: hub-hint-pulse 2.5s ease-in-out infinite;
}
.hub-add-hint span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    white-space: nowrap;
    letter-spacing: 0.3px;
    font-style: italic;
    margin-top: 2px;
}
@keyframes hub-hint-pulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.9; }
}

/* Actions below timeline */
.hub-tl-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 32px;
}
.hub-tl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text-sec);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.hub-tl-btn:hover {
    border-color: var(--accent);
    color: var(--accent-fg);
}
.hub-tl-btn.hub-tl-btn-primary {
    border: 1px solid var(--accent);
    color: #1a0f08;
    background: linear-gradient(180deg, var(--accent-light), var(--accent));
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 10px 22px;
    box-shadow: 0 0 18px rgba(255, 138, 58, 0.35);
}
.hub-tl-btn.hub-tl-btn-primary:hover {
    background: linear-gradient(180deg, #ffd0a3, var(--accent));
    color: #1a0f08;
    box-shadow: 0 0 28px rgba(255, 138, 58, 0.5);
    transform: translateY(-1px);
}
.hub-tl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   FOOTER
   ============================================================ */

.hub-footer {
    margin-top: auto;
    padding: 32px 32px 24px;
    font-size: 10px;
    color: var(--text-sec);
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-transform: uppercase;
}

/* ============================================================
   MODAL DIALOG / TOAST
   ============================================================ */

.hub-overlay {
    position: fixed; inset: 0;
    background: rgba(20, 16, 8, 0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}
.hub-dialog {
    background: var(--panel);
    color: var(--text);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px 28px;
    max-width: calc(100vw - 32px);
    width: 380px;
}
.hub-dialog h2 {
    margin: 0 0 6px;
    font: 700 18px/1.2 inherit;
}
.hub-dialog p {
    margin: 0 0 16px;
    color: var(--text-mid);
    font-size: 13px;
    line-height: 1.5;
}
.hub-user-list {
    display: flex; flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 14px;
}
.hub-user-empty {
    display: none;
    color: var(--text-dim);
    font-size: 12px;
    font-style: italic;
    padding: 10px 0;
    text-align: center;
}
.hub-user-list:empty + .hub-user-empty { display: block; }

.hub-user-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text);
    font: 600 13px inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.hub-user-row:hover {
    border-color: var(--accent);
    background: var(--accent-faint);
}
.hub-user-row.is-active {
    border-color: var(--accent);
    background: var(--accent-faint);
    color: var(--accent-fg);
}
.hub-user-row .hub-user-del {
    background: transparent;
    border: 0;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
}
.hub-user-row .hub-user-del:hover {
    color: var(--red);
    background: rgba(197, 48, 45, 0.1);
}

.hub-input-row {
    display: flex; gap: 6px; margin-bottom: 6px;
}
.hub-input-row input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--text);
    font: 600 13px inherit;
    outline: none;
}
.hub-input-row input:focus { border-color: var(--accent); }
.hub-input-row button {
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: 700 12px inherit;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.hub-input-row button:hover { background: var(--accent-fg); }

.hub-dialog-error {
    color: var(--red);
    font-size: 12px;
    min-height: 16px;
    margin-top: 4px;
}
.hub-dialog-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 16px;
}
.hub-btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: 600 13px inherit;
}
.hub-btn-secondary:hover { border-color: var(--border-strong); }
.hub-btn-primary {
    background: var(--accent);
    color: #fff;
    border: 0;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: 700 13px inherit;
}
.hub-btn-primary:hover { background: var(--accent-fg); }

.hub-toast {
    position: fixed;
    left: 50%; bottom: 36px;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--paper);
    padding: 12px 18px;
    border-radius: 999px;
    font: 600 13px inherit;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms, transform 200ms;
    z-index: 110;
}
.hub-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}
