:root {
  --bg: #0b1220;
  --bg-raised: #121a2b;
  --bg-sunken: #0a0f1a;
  --line: #22304a;
  --text: #e6ebf5;
  --muted: #93a0b8;
  --brand: #10b981;
  --warn-bg: #3a2a0b;
  --warn-line: #a16207;
  --info-bg: #0d2540;
  --info-line: #2563eb;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.35);
  --radius: 14px;
  color-scheme: dark;
}

/* Dark only: the ASCII fields fade from near-black to bright. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

code {
  font: 0.88em ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.05em 0.35em;
}

/* Header */

.hero {
  position: relative; overflow: hidden; isolation: isolate; cursor: crosshair;
  padding: 72px 0 48px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 1; pointer-events: none; }
.hero-inner { position: relative; }
.kicker, .tagline { position: relative; z-index: 2; }
.kicker { margin: 0 0 18px; font: 0.95rem 'DM Mono', ui-monospace, monospace; color: var(--brand); }
.hero-title {
  position: relative; z-index: 0; margin: 0 0 28px;
  font-weight: 800; text-transform: uppercase;
  font-size: clamp(64px, 15vw, 200px); line-height: 0.84; letter-spacing: -0.035em;
  /* Faint silhouette under the glyphs. The canvas does the real drawing. */
  color: color-mix(in srgb, var(--brand) 14%, transparent);
}
.hero-title span { display: block; width: fit-content; }
.tagline { color: var(--text); opacity: 0.85; max-width: 600px; margin: 0; font-size: 1.1rem; }
/* Toolbar */

.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; margin-bottom: 22px;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg-raised); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 0.9rem; cursor: pointer;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #04150f; font-weight: 600; }
.search input {
  width: min(280px, 100%); border: 1px solid var(--line); background: var(--bg-raised);
  color: var(--text); border-radius: 10px; padding: 9px 12px; font: inherit;
}
.search { flex: 0 1 280px; }
.search input:focus, .chip:focus-visible, .card-button:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* Cards */

.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent, var(--line)); }

.cover { aspect-ratio: 16 / 9; background: var(--bg-sunken); overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Generated cover: the mod's glyph traced by an ASCII field */
.cover-ascii {
  position: relative; width: 100%; height: 100%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%), #0a0f1a;
}
.cover-ascii canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cover-glyph {
  font-weight: 800; line-height: 1; font-size: 118px;
  color: color-mix(in srgb, var(--accent) 12%, transparent);
}
.cover-glyph-path { width: 1em; height: 1em; }
.stage .cover-glyph { font-size: min(300px, 40vw); }

.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card h3 { margin: 0; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); flex: 1; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 0.75rem; padding: 2px 9px; border-radius: 999px;
  background: var(--bg-sunken); border: 1px solid var(--line); color: var(--muted);
}
.tag.warn { color: #fbbf24; border-color: var(--warn-line); }

/* The mod's name is the button, and its click area covers the whole card */
.card-button {
  border: 0; background: none; color: var(--text); text-align: left;
  font: inherit; font-weight: 700; padding: 0; cursor: pointer;
}
.card-button::after { content: ""; position: absolute; inset: 0; }
.card:hover .card-button { color: var(--accent, var(--brand)); }
.warn-mark { margin-left: 7px; color: #fbbf24; font-size: 0.9em; }

/* Type tags stay hidden until the card is hovered or focused */
.card-tags {
  position: absolute; top: 10px; left: 10px; right: 10px; pointer-events: none;
  opacity: 0; transition: opacity 0.15s ease;
}
.card-tags .tag { background: rgb(10 15 26 / 0.85); color: var(--text); backdrop-filter: blur(4px); }
.card:hover .card-tags, .card:focus-within .card-tags { opacity: 1; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* Footer */

.footer { margin-top: 56px; padding-top: 24px; padding-bottom: 48px; border-top: 1px solid var(--line); color: var(--muted); }
.footer h2 { font-size: 1rem; color: var(--text); margin: 0 0 8px; }
.footer ul { margin: 0; padding-left: 20px; }

/* Popup */

dialog {
  width: min(920px, calc(100% - 32px)); max-height: calc(100% - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(3 7 18 / 0.7); backdrop-filter: blur(3px); }
.dialog-inner { position: relative; padding: 24px; }
.close {
  position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-sunken); color: var(--text);
  font-size: 1.4rem; line-height: 1; cursor: pointer; z-index: 2;
}

.dialog-head { padding-right: 48px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0 0 6px; font-size: 1.6rem; }
.dialog-head .meta .tag:first-child { font-family: ui-monospace, Consolas, monospace; }

.gallery { margin-bottom: 22px; }
.stage {
  position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden;
  background: var(--bg-sunken); border: 1px solid var(--line);
}
.stage > * { width: 100%; height: 100%; }
.stage img, .stage video { object-fit: contain; display: block; background: #000; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 1;
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgb(0 0 0 / 0.55); color: #fff; font-size: 1.3rem;
}
.nav.prev { left: 10px; }
.nav.next { right: 10px; }
.caption { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.92rem; margin: 10px 2px 0; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
.thumb {
  flex: 0 0 96px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; padding: 0;
  border: 2px solid transparent; background: var(--bg-sunken); cursor: pointer; color: var(--muted);
  font: 600 0.72rem Inter, sans-serif;
}
.thumb[aria-current="true"] { border-color: var(--accent, var(--brand)); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .thumb-label { display: grid; place-items: center; width: 100%; height: 100%; }

.placeholder {
  display: grid; place-items: center; text-align: center; gap: 6px; padding: 20px;
  color: var(--muted); border: 2px dashed var(--line); border-radius: 12px;
  background: repeating-linear-gradient(45deg, transparent 0 12px, rgb(127 127 127 / 0.06) 12px 24px);
}
.placeholder strong { color: var(--text); display: block; }

.columns { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; }
.columns h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 8px; }
.columns section + section { margin-top: 18px; }
.columns ul, .columns ol { margin: 0; padding-left: 20px; }
.columns li + li { margin-top: 6px; }
.about { margin: 0 0 18px; font-size: 1.05rem; }

.commands { list-style: none; padding: 0 !important; display: grid; gap: 8px; }
.commands li { margin: 0 !important; }
.commands code { display: inline-block; }
.commands span { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.notice { border-left: 4px solid; border-radius: 8px; padding: 12px 14px; margin-bottom: 18px; }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.notice.info { background: var(--info-bg); border-color: var(--info-line); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.button {
  display: inline-block; padding: 9px 16px; border-radius: 10px; font-weight: 600; text-decoration: none;
  background: var(--accent, var(--brand)); color: #fff;
}
.button.secondary { background: var(--bg-sunken); color: var(--text); border: 1px solid var(--line); }

/* Mock Minecraft chat */

.mc-scene {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 0 10px 10px; overflow: hidden;
  background:
    linear-gradient(transparent 62%, #3d7a2a 62%, #2f5f20 70%, #5b4126 70%, #4a3520),
    linear-gradient(#5aa0e6, #9fd0ff 62%);
  font-family: VT323, ui-monospace, Consolas, monospace;
  font-size: clamp(14px, 2.6vw, 21px); line-height: 1.12;
  text-shadow: 2px 2px 0 rgb(0 0 0 / 0.55);
}
.mc-chat { width: min(78%, 560px); background: rgb(0 0 0 / 0.5); padding: 4px 0; }
.mc-line { position: relative; padding: 1px 8px; color: #fff; white-space: pre-wrap; }
.mc-line.hovered { background: rgb(255 255 255 / 0.12); }
.mc-popup {
  position: absolute; left: calc(100% + 6px); top: 50%; transform: translateY(-50%);
  background: #1a1a2e; border: 2px solid #2b1a5a; color: #55ff55; padding: 1px 8px; white-space: nowrap;
}
.mc-input {
  margin-top: 6px; margin-right: 10px; background: rgb(0 0 0 / 0.5); color: #fff; padding: 3px 8px;
}
.mc-input::after { content: "_"; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.b { font-weight: 700; }
.u { text-decoration: underline; }
.i { font-style: italic; }
.s { text-decoration: line-through; }

@media (max-width: 720px) {
  .columns { grid-template-columns: 1fr; }
  .dialog-inner { padding: 18px; }
  dialog { width: 100%; max-width: none; max-height: 100%; height: 100%; margin: 0; border-radius: 0; border: 0; }
  .mc-chat { width: 92%; }
  .mc-popup { left: auto; right: 6px; }
}

/* Pack: the download bar and the add-to-pack toggles */

button.button { border: 0; font: inherit; font-weight: 600; cursor: pointer; }
button.button:disabled { opacity: 0.5; cursor: default; }

.card-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.pack-toggle {
  /* Sits above the card's full-size "More info" click area */
  position: relative; z-index: 1;
  border: 1px solid var(--line); background: var(--bg-sunken); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 0.85rem; cursor: pointer; white-space: nowrap;
}
.pack-toggle:hover { border-color: var(--accent, var(--brand)); }
.pack-toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent, var(--brand)) 22%, var(--bg-sunken));
  border-color: var(--accent, var(--brand)); font-weight: 600;
}
.pack-toggle:disabled { opacity: 0.55; cursor: default; }
.pack-toggle.button { border-radius: 10px; padding: 9px 16px; font-size: 1rem; }

.pack {
  position: sticky; bottom: 0; z-index: 5; margin-top: 28px;
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgb(0 0 0 / 0.3);
}
.pack-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-top: 12px; padding-bottom: 12px; }
.pack-status { flex: 1 1 260px; margin: 0; color: var(--muted); font-size: 0.9rem; }
.pack-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pack .button { background: var(--brand); color: #04150f; }

/* Version picker: pops up from a download button */
.mc-picker {
  position: fixed; inset: auto; margin: 0; width: min(320px, calc(100vw - 16px));
  max-height: min(420px, calc(100vh - 16px)); overflow-y: auto;
  padding: 8px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow);
}
.mc-picker-title { margin: 4px 8px 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.mc-option {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%;
  border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit;
  padding: 9px 10px; text-align: left; cursor: pointer;
}
.mc-option span { color: var(--muted); font-size: 0.85rem; text-align: right; }
.mc-option:hover:not(:disabled), .mc-option:focus-visible { background: var(--bg-sunken); outline: none; }
.mc-option[aria-current="true"] strong::after { content: " · last used"; font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.mc-option:disabled { opacity: 0.45; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .card, .card:hover { transition: none; transform: none; }
  .mc-input::after { animation: none; }
}
