/* =====================================================================
   GachaHub — style.css
   Modern, mobile-first layout using CSS custom properties.
   Light theme by default; add data-theme="dark" on <html> to flip.
   ===================================================================== */

/* -------- Design tokens (CSS Variables) ---------------------------- */
:root {
    /* Brand palette — soft, playful, "gacha" pastel */
    --brand:        #7c5cff;
    --brand-dark:   #5b3fd6;
    --brand-soft:   #ede8ff;
    --accent:       #ff6fb5;

    /* Surfaces + text (light theme) */
    --bg:           #f6f7fb;
    --surface:      #ffffff;
    --surface-2:    #f1f2f8;
    --border:       #e4e6ef;
    --text:         #1c1d29;
    --text-muted:   #6b6d80;

    /* Feedback */
    --success:      #2fbf71;
    --danger:       #e5484d;

    /* Shape + motion */
    --radius:       14px;
    --radius-sm:    9px;
    --shadow:       0 6px 20px rgba(28, 29, 41, 0.08);
    --shadow-hover: 0 10px 28px rgba(124, 92, 255, 0.18);
    --transition:   180ms ease;

    --maxw:         1180px;
}

/* Dark theme overrides */
:root[data-theme="dark"] {
    --brand-soft:   #241f3d;
    --bg:           #0f1017;
    --surface:      #191a24;
    --surface-2:    #21222f;
    --border:       #2c2e3e;
    --text:         #ecedf5;
    --text-muted:   #9a9cb2;
    --shadow:       0 6px 20px rgba(0, 0, 0, 0.4);
}

/* Respect OS preference when no explicit theme is chosen */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand-soft:   #241f3d;
        --bg:           #0f1017;
        --surface:      #191a24;
        --surface-2:    #21222f;
        --border:       #2c2e3e;
        --text:         #ecedf5;
        --text-muted:   #9a9cb2;
        --shadow:       0 6px 20px rgba(0, 0, 0, 0.4);
    }
}

/* -------- Base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    /* Soft themed gacha backdrop. To use your OWN image instead, add:
       background-image: url('uploads/your-bg.png'); background-size: cover;
       background-attachment: fixed; (keep it below the content — it is) */
    background:
        radial-gradient(1200px 600px at 12% -10%, rgba(124, 92, 255, 0.10), transparent 60%),
        radial-gradient(1000px 520px at 112% 8%, rgba(255, 111, 181, 0.10), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding-inline: clamp(16px, 4vw, 28px);
}

/* -------- Navigation Bar ------------------------------------------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface); /* fallback for browsers without color-mix() */
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.navbar__inner {
    display: flex;
    align-items: center;
    gap: 18px;
    height: 64px;
}
.navbar__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text);
}
.navbar__brand span { color: var(--brand); }
.navbar__links {
    display: flex;
    gap: 6px;
    margin-left: auto;
    align-items: center;
}
.navbar__links a {
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
}
.navbar__links a:hover {
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
}

/* -------- Buttons -------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--block { width: 100%; }
.btn--copy.is-copied { background: var(--success); color: #fff; border-color: transparent; }

/* -------- Hero ----------------------------------------------------- */
.hero {
    padding: clamp(36px, 7vw, 72px) 0 clamp(20px, 4vw, 40px);
    text-align: center;
}
.hero h1 {
    margin: 0 0 12px;
    font-size: clamp(1.9rem, 5vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.hero h1 .grad {
    background: linear-gradient(90deg, var(--brand), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero p { color: var(--text-muted); max-width: 620px; margin: 0 auto; font-size: 1.05rem; }

/* -------- Search / Filter Toolbar ---------------------------------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.toolbar__search {
    flex: 1 1 240px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
}
.toolbar__search input {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
}
.toolbar__filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* -------- OC Code Grid --------------------------------------------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 18px;
}
.card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.card__thumb {
    aspect-ratio: 16 / 10;
    background:
        linear-gradient(135deg, var(--brand-soft), var(--surface-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    color: var(--brand);
    overflow: hidden;
}
.card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.card__body { padding: 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card__title { margin: 0; font-size: 1.02rem; font-weight: 700; }
.card__meta { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); }

/* Tag badges */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--brand-dark);
    background: var(--brand-soft);
    padding: 3px 9px;
    border-radius: 999px;
}
:root[data-theme="dark"] .tag { color: #cdbcff; }

/* Game badge */
.badge-game {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
}

.card__footer { margin-top: auto; }

/* Empty-state when a search returns nothing */
.empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 12px;
    color: var(--text-muted);
}

/* -------- Toast Notifications -------------------------------------- */
.toast-wrap {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}
.toast {
    background: var(--text);
    color: var(--bg);
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 220ms ease, transform 220ms ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--success); color: #fff; }
.toast--error   { background: var(--danger);  color: #fff; }

/* -------- Footer --------------------------------------------------- */
.footer {
    border-top: 1px solid var(--border);
    margin-top: 48px;
    padding: 28px 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
}

/* -------- Responsive tweaks ---------------------------------------- */
@media (max-width: 640px) {
    .navbar__links a:not(.btn) { display: none; } /* collapse text links on phones */
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar__filters { justify-content: flex-start; overflow-x: auto; }
}

/* Accessibility: honor reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* =====================================================================
   MVP additions — nav states, hero CTA, gallery, forms, detail page
   ===================================================================== */

/* -------- Nav: active link + "coming soon" chips ------------------- */
.navbar__links a[aria-current="page"] {
    color: var(--text);
    background: var(--surface-2);
}
.navbar__soon {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    opacity: 0.65;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: default;
    -webkit-user-select: none;
    user-select: none;
}
.navbar__soon small {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--brand-soft);
    color: var(--brand-dark);
    padding: 2px 5px;
    border-radius: 6px;
}
:root[data-theme="dark"] .navbar__soon small { color: #cdbcff; }

/* Inline logout form sits flush with the other nav buttons */
.nav-logout { margin: 0; display: inline-flex; }

/* -------- Hero CTA row --------------------------------------------- */
.hero__cta {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 22px;
}

/* -------- Section heading ------------------------------------------ */
.section-head { margin: 8px 0 18px; }
.section-head h1 { margin: 0 0 4px; font-size: clamp(1.5rem, 4vw, 2rem); }
.section-head p { margin: 0; color: var(--text-muted); }
.section-head__row { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; }

/* -------- Card links (title/thumb are now anchors) ---------------- */
.card__thumb { text-decoration: none; }
.card__title a { color: var(--text); text-decoration: none; }
.card__title a:hover { color: var(--brand); }

/* -------- Gallery variant: screenshot-forward, taller portrait ---- */
.grid--gallery {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.card--gallery .card__thumb { aspect-ratio: 3 / 4; font-size: 3rem; }

/* -------- Forms (register / login / submit) ----------------------- */
.form-wrap {
    max-width: 460px;
    margin: 28px auto;
}
.form-wrap--wide { max-width: 640px; }
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(20px, 4vw, 32px);
}
.form-card h1 { margin: 0 0 6px; font-size: 1.5rem; }
.form-card .sub { color: var(--text-muted); margin: 0 0 20px; font-size: 0.95rem; }
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.field .hint { color: var(--text-muted); font-size: 0.8rem; margin-top: 5px; }
.form-foot { margin-top: 18px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* -------- Alerts / flash messages --------------------------------- */
.alert {
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert--error {
    background: var(--surface-2); /* fallbacks first for older browsers */
    border-color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}
.alert--success {
    background: var(--surface-2);
    border-color: var(--success);
    background: color-mix(in srgb, var(--success) 12%, transparent);
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

/* -------- Detail page (code.php) ---------------------------------- */
.detail {
    display: grid;
    grid-template-columns: minmax(0, 420px) 1fr;
    gap: 26px;
    margin: 24px 0;
    align-items: start;
}
.detail__media {
    background: linear-gradient(135deg, var(--brand-soft), var(--surface-2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    aspect-ratio: 3 / 4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: var(--brand);
    overflow: hidden;
}
.detail__media img { width: 100%; height: 100%; object-fit: cover; }
.detail__info h1 { margin: 0 0 8px; font-size: clamp(1.4rem, 4vw, 2rem); }
.detail__meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 14px; }
.code-box {
    position: relative;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin: 14px 0;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    max-height: 220px;
    overflow: auto;
    word-break: break-all;
    white-space: pre-wrap;
    color: var(--text);
}

/* -------- Utilities ----------------------------------------------- */
.link-muted { color: var(--text-muted); }
.stack-lg > * + * { margin-top: 18px; }
.text-center { text-align: center; }
.price { font-weight: 800; color: var(--brand); }
.price--lg { font-size: 1.7rem; margin: 8px 0 4px; }

/* Row of action buttons (e.g. dashboard Edit / Delete) */
.actions { display: flex; gap: 8px; align-items: stretch; }
.actions form { flex: 1; margin: 0; }
.actions .btn { flex: 1; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { background: #27a862; }

@media (max-width: 720px) {
    .detail { grid-template-columns: 1fr; }
    .detail__media { max-width: 320px; margin-inline: auto; }
}

/* =====================================================================
   Ambience — 3 animations: aurora drift, floating feathers, title shimmer.
   Pure CSS/JS, no external images. All auto-disable under reduced-motion
   (see the global rule near the top of this file).
   ===================================================================== */

/* (1) Animated aurora blobs, behind all content */
body::before {
    content: "";
    position: fixed;
    inset: -20%;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(38vmax 38vmax at 20% 25%, rgba(124, 92, 255, 0.14), transparent 60%),
        radial-gradient(34vmax 34vmax at 82% 18%, rgba(255, 111, 181, 0.12), transparent 60%),
        radial-gradient(30vmax 30vmax at 62% 82%, rgba(124, 92, 255, 0.10), transparent 60%);
    animation: auroraDrift 26s ease-in-out infinite alternate;
}
:root[data-theme="dark"] body::before {
    background:
        radial-gradient(38vmax 38vmax at 20% 25%, rgba(124, 92, 255, 0.22), transparent 60%),
        radial-gradient(34vmax 34vmax at 82% 18%, rgba(255, 111, 181, 0.16), transparent 60%),
        radial-gradient(30vmax 30vmax at 62% 82%, rgba(124, 92, 255, 0.18), transparent 60%);
}
@keyframes auroraDrift {
    0%   { transform: translate3d(-3%, -2%, 0) scale(1); }
    50%  { transform: translate3d(2%, 3%, 0) scale(1.08); }
    100% { transform: translate3d(3%, -1%, 0) scale(1.03); }
}

/* (2) Falling feathers / petals layer (populated by app.js Ambience) */
.feathers {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}
.feather {
    position: absolute;
    top: -8vh;
    opacity: 0;
    line-height: 1;
    -webkit-user-select: none;
    user-select: none;
    will-change: transform, opacity;
    animation: featherFall linear infinite;
    filter: drop-shadow(0 3px 4px rgba(124, 92, 255, 0.18));
}
@keyframes featherFall {
    0%   { transform: translate3d(0, -10vh, 0) rotate(0deg);                   opacity: 0; }
    8%   { opacity: 0.75; }
    25%  { transform: translate3d(var(--drift, 20px), 22vh, 0) rotate(70deg); }
    50%  { transform: translate3d(calc(var(--drift, 20px) * -1), 52vh, 0) rotate(150deg); }
    75%  { transform: translate3d(var(--drift, 20px), 80vh, 0) rotate(250deg); }
    92%  { opacity: 0.75; }
    100% { transform: translate3d(0, 112vh, 0) rotate(340deg);                 opacity: 0; }
}

/* (3) Shimmering gradient hero title */
.hero h1 .grad {
    background-image: linear-gradient(90deg, var(--brand), var(--accent), var(--brand));
    background-size: 200% auto;
    animation: shimmer 6s linear infinite;
}
@keyframes shimmer {
    to { background-position: 200% center; }
}
