/* ============================================
   100K Stronghold Summary — Minecraft Theme
   ============================================ */

:root {
    /* Minecraft-inspired palette */
    --mc-stone: #6b6b6b;
    --mc-stone-light: #8b8b8b;
    --mc-stone-dark: #4a4a4a;
    --mc-cobble: #5c5c5c;
    --mc-cobble-border: #3d3d3d;
    --mc-cave: #1a1a1e;
    --mc-cave-deep: #0f0f12;
    --mc-end-purple: #7b2cbf;
    --mc-end-purple-bright: #9d4edd;
    --mc-end-purple-glow: rgba(157, 78, 221, 0.4);
    --mc-ender-eye: #00ff88;
    --mc-ender-eye-dim: #00cc6a;
    --mc-lava: #ff6b35;
    --mc-lava-dim: #e85a2a;
    --mc-moss: #4a7c59;
    --mc-gold: #ffd93d;
    --mc-text: #e8e6e3;
    --mc-text-muted: #9ca3a8;
    --mc-panel: rgba(30, 30, 35, 0.85);
    --mc-panel-border: rgba(123, 44, 191, 0.35);
    --mc-shadow: rgba(0, 0, 0, 0.5);

    /* Legacy compatibility (map old vars) */
    --foreground: var(--mc-text);
    --background: var(--mc-cave);
    --stroke: var(--mc-stone-dark);
    --background-light: var(--mc-cobble);
    --foreground-muted: var(--mc-text-muted);
    --oc-gray-0: #f8f9fa;
    --oc-gray-6: #868e96;
    --oc-gray-8: #343a40;
    --oc-gray-9: #212529;
    --oc-red-3: #ffa8a8;
    --oc-green-3: #8ce99a;
    --oc-violet-2: #d0bfff;
    --oc-violet-3: #b197fc;
    --oc-cyan-4: #3bc9db;
    --oc-yellow-3: #ffe066;

    --text-h1: 2.5rem;
    --text-h2: 1.75rem;
    --text-h3: 1.35rem;
    --text-h4: 1.2rem;
    --text-h5: 1.1rem;
    --text-h6: 1rem;
    --text-large: var(--text-h6);
    --text-p: 1rem;
    --text-small: 0.875rem;
    --text-xsmall: 0.75rem;

    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-fast: 0.2s var(--ease-out-expo);
    --transition-mid: 0.35s var(--ease-out-expo);
    --transition-slow: 0.5s var(--ease-out-expo);
}

/* ---- Reset & base ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
}

body.mc-theme {
    background: var(--mc-cave);
    color: var(--mc-text);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    line-height: 1.65;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle animated gradient background */
body.mc-theme::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(ellipse 120% 60% at 50% -20%, rgba(123, 44, 191, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 80% 40% at 80% 100%, rgba(0, 255, 136, 0.04) 0%, transparent 45%),
        var(--mc-cave);
}

/* Optional noise overlay for texture */
body.mc-theme::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* ---- Hero ---- */
.hero {
    text-align: center;
    padding: clamp(2.5rem, 8vw, 4rem) 1rem clamp(2rem, 5vw, 3rem);
    margin-bottom: 1.5rem;
    animation: heroFade 1s var(--ease-out-expo) both;
}

.hero h1 {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    color: var(--mc-text);
    text-shadow:
        0 0 20px var(--mc-end-purple-glow),
        0 2px 0 var(--mc-stone-dark);
    letter-spacing: 0.02em;
    line-height: 1.6;
    margin-bottom: 0.75rem;
    animation: heroFade 1s var(--ease-out-expo) both, heroGlow 4s ease-in-out 1s infinite;
}

@keyframes heroGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.08); }
}

.hero-sub {
    font-size: var(--text-small);
    color: var(--mc-text-muted);
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

@keyframes heroFade {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Layout ---- */
.main-content {
    max-width: 56rem;
    margin: 0 auto;
    padding: 0 clamp(1rem, 4vw, 2rem) 3rem;
}

/* ---- Typography ---- */
h1 { font-size: var(--text-h1); }
h2 {
    font-size: var(--text-h2);
    margin-top: 1.5em;
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(0.75rem, 2.5vw, 0.95rem);
    color: var(--mc-ender-eye-dim);
    letter-spacing: 0.02em;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--mc-panel-border);
    scroll-margin-top: 1rem;
    animation: sectionFade 0.6s var(--ease-out-expo) both;
}
h3 {
    font-size: var(--text-h3);
    margin-top: 1.25em;
    color: var(--mc-stone-light);
    font-weight: 600;
    animation: sectionFade 0.6s var(--ease-out-expo) both;
}
h4 { font-size: var(--text-h4); margin-top: 1em; }
h5 { font-size: var(--text-h5); margin-top: 1em; }
h6 { font-size: var(--text-h6); margin-top: 1em; }

.large { font-size: var(--text-large); }
.small { font-size: var(--text-small); }

.negative { color: var(--oc-red-3); }
.positive { color: var(--oc-green-3); }

.disclaimer {
    font-size: var(--text-small);
    color: var(--mc-text-muted);
}

p {
    margin-block-end: 1em;
    animation: textFade 0.5s var(--ease-out-expo) both;
}

/* Stagger children of main for a subtle cascade */
.main-content > p:nth-child(1) { animation-delay: 0.05s; }
.main-content > p:nth-child(2) { animation-delay: 0.1s; }
.main-content > p:nth-child(3) { animation-delay: 0.15s; }
.main-content > p:nth-child(4) { animation-delay: 0.2s; }
.main-content > p:nth-child(5) { animation-delay: 0.25s; }
.main-content > p:nth-child(6) { animation-delay: 0.3s; }
.main-content > .contents { animation: textFade 0.5s var(--ease-out-expo) 0.35s both; }

@keyframes textFade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sectionFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Links ---- */
.contents li:has(a), a {
    text-decoration: none;
    color: var(--mc-end-purple-bright);
    transition: color var(--transition-fast), text-shadow var(--transition-fast), transform var(--transition-fast);
}
.contents li:has(a):hover, a:hover {
    color: var(--mc-ender-eye);
    text-shadow: 0 0 12px var(--mc-end-purple-glow);
}

/* ---- Contents / TOC ---- */
.contents {
    background: var(--mc-panel);
    border: 1px solid var(--mc-panel-border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 1.5em 0;
    box-shadow: 0 4px 24px var(--mc-shadow);
    animation: sectionFade 0.6s var(--ease-out-expo) 0.2s both;
}

.contents p {
    margin-block-end: 0;
    text-decoration: underline solid;
    text-underline-offset: 3px;
}

.contents ul {
    list-style: none;
    margin-top: 0.5rem;
}

.contents li {
    margin-inline-start: 0;
    padding: 0.25em 0;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    margin-left: 0;
    transition: border-color var(--transition-fast), padding-left var(--transition-fast);
}

.contents li:hover {
    border-left-color: var(--mc-end-purple);
}

.contents ul ul {
    margin-left: 0.5rem;
}

.contents ul ul li {
    padding-left: 1rem;
}

li { margin-inline-start: 1em; }
ul > ul li { margin-inline-start: 2em; }

/* ---- Sections ---- */
section {
    margin: 2.5rem 0;
    padding: 1.5rem 0;
    border-radius: 12px;
    animation: sectionFade 0.6s var(--ease-out-expo) both;
}

section:nth-of-type(1) { animation-delay: 0.1s; }
section:nth-of-type(2) { animation-delay: 0.15s; }
section:nth-of-type(3) { animation-delay: 0.2s; }
section:nth-of-type(4) { animation-delay: 0.25s; }
section:nth-of-type(5) { animation-delay: 0.3s; }
section:nth-of-type(6) { animation-delay: 0.35s; }
section:nth-of-type(7) { animation-delay: 0.4s; }
section:nth-of-type(8) { animation-delay: 0.45s; }

/* ---- Tables (stronghold / stone style) ---- */
table {
    border-collapse: collapse;
    margin-block-end: 1.25em;
    max-width: 100%;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px var(--mc-shadow);
    animation: tableFade 0.5s var(--ease-out-expo) both;
}

@keyframes tableFade {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

table th {
    background: var(--mc-cobble);
    color: var(--mc-text);
    border-bottom: 3px solid var(--mc-end-purple);
    padding: 0.6em 0.75em;
    text-align: center;
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.9em;
}

table tr td {
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 0.5em 0.75em;
    text-align: center;
    transition: background var(--transition-fast);
}

table :is(th, td)[l] { text-align: left; }
table :is(th, td)[c] { text-align: center; }
table :is(th, td)[r] { text-align: right; }
table :is(th, td)[b], table:not(.nobold) tr td:first-of-type { font-weight: 600; }

table tbody tr {
    background: rgba(26, 26, 30, 0.6);
}

table tbody tr:hover {
    background: rgba(123, 44, 191, 0.12);
}

table tbody tr td {
    transition: background var(--transition-mid);
}

/* ---- Searchable/sortable tables ---- */
.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.table-search {
    flex: 1;
    min-width: 12rem;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--mc-text);
    background: var(--mc-panel);
    border: 1px solid var(--mc-panel-border);
    border-radius: 6px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.table-search::placeholder {
    color: var(--mc-text-muted);
}

.table-search:focus {
    outline: none;
    border-color: var(--mc-end-purple);
    box-shadow: 0 0 0 2px var(--mc-end-purple-glow);
}

.table-count {
    font-size: var(--text-small);
    color: var(--mc-text-muted);
}

table th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 1.25rem;
    position: relative;
    transition: color var(--transition-fast), background var(--transition-fast);
}

table th.sortable:hover {
    color: var(--mc-ender-eye);
    background: var(--mc-stone-dark);
}

table th.sortable::after {
    content: "⇅";
    position: absolute;
    right: 0.35rem;
    opacity: 0.4;
    font-size: 0.75em;
}

table th.sortable.sort-asc::after {
    content: "↑";
    opacity: 1;
    color: var(--mc-ender-eye);
}

table th.sortable.sort-desc::after {
    content: "↓";
    opacity: 1;
    color: var(--mc-ender-eye);
}

/* Collapsible table wrapper */
.table-wrapper {
    margin-bottom: 1.25em;
}

.table-wrapper .table-container {
    overflow: hidden;
    transition: max-height 0.4s var(--ease-out-expo), opacity 0.3s ease;
}

.table-wrapper.collapsed .table-container {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    pointer-events: none;
}

.table-wrapper.collapsed .table-toolbar .table-search {
    opacity: 0.6;
}

.table-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.65rem;
    font-family: inherit;
    font-size: var(--text-small);
    color: var(--mc-text-muted);
    background: transparent;
    border: 1px solid var(--mc-panel-border);
    border-radius: 6px;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.table-toggle:hover {
    color: var(--mc-ender-eye);
    border-color: var(--mc-end-purple);
    background: rgba(123, 44, 191, 0.1);
}

.table-toggle .table-toggle-icon {
    display: inline-block;
    transition: transform 0.25s var(--ease-out-expo);
}

.table-wrapper.collapsed .table-toggle .table-toggle-icon {
    transform: rotate(-90deg);
}

/* ---- Copy / tooltip ---- */
[data-copy] {
    text-decoration-line: underline;
    text-decoration-style: dotted;
    cursor: copy;
    white-space: nowrap;
    transition: color var(--transition-fast), text-shadow var(--transition-fast);
}

[data-copy]:hover {
    color: var(--mc-ender-eye);
    text-shadow: 0 0 8px var(--mc-end-purple-glow);
}

[id^="fav-"]:target {
    color: var(--mc-gold);
}

[data-tippy-content]:after {
    content: "?";
    font-weight: 600;
    font-size: var(--text-xsmall);
    vertical-align: super;
    color: var(--oc-cyan-4);
    padding: 0 0.25em;
}

/* ---- Footer ---- */
footer {
    font-size: var(--text-xsmall);
    color: var(--mc-text-muted);
    margin-block-start: 3rem;
    padding: 1.5rem 1rem;
    border-top: 1px solid var(--mc-panel-border);
    text-align: center;
    animation: textFade 0.6s var(--ease-out-expo) 0.5s both;
}

footer p {
    max-width: 100%;
    margin-block-end: 0;
}

/* ---- Scroll-triggered fade (optional enhancement) ---- */
@media (prefers-reduced-motion: no-preference) {
    .main-content p,
    .main-content .contents,
    section,
    table {
        animation-duration: 0.7s;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hero,
    .hero h1,
    .main-content p,
    .main-content .contents,
    section,
    h2, h3,
    table,
    footer {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .hero h1 {
        filter: none;
    }
}

/* ---- Responsive ---- */
@media (max-width: 30rem) {
    body.mc-theme {
        padding: 0.5rem 0;
    }
    .hero h1 {
        font-size: 0.85rem;
        line-height: 1.8;
    }
    .main-content {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    table th, table td {
        padding: 0.4em 0.35em;
        font-size: 0.85rem;
    }
}

/* Legacy grid override: single column centered */
body.mc-theme {
    display: block;
}

body.mc-theme > * {
    grid-column: unset;
}
