/* Perso Adventures — Minecraft inventory-GUI theme.
   Every colour, size, and bevel is a token in :root below; rules only reference
   tokens. Pixel-font sizes are integer px so Monocraft stays crisp. The dirt
   backdrop is a procedurally generated tile (no Mojang assets). */

@font-face {
  font-family: "Monocraft";
  src: url("fonts/Monocraft.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  /* ---------- palette ---------- */
  --c-line: #1c1208;              /* hard near-black outline */
  --c-bg: #120b06;               /* page base behind dirt */
  --c-dirt-base: #1a1109;        /* body dirt tint */
  --c-dirt-solid: #5b3f26;       /* topbar dirt */
  --c-grass: #5fae3b;
  --c-grass-hi: #7bd152;
  --c-grass-lo: #4f9a39;
  --c-gold: #ffd44d;             /* button hover text (MC yellow) */
  --c-amber: #d98a2b;            /* bedrock tag */
  --c-bedrock: #5fd6ea;          /* bedrock player name (cyan) */
  --c-redstone: #c0392b;

  /* world-slice backdrop (assets/tex/world.png sits on this base; the scrim
     uses the glow + depth-shade) */
  --c-strata-bedrock: #16161c;       /* fill below the texture */
  --c-lava-glow: rgba(255, 122, 26, 0.40);
  --c-depth-shade: rgba(0, 0, 0, 0.32);

  /* gray GUI panels */
  --c-panel: #c6c6c6;
  --c-panel-hi: #ffffff;
  --c-panel-lo: #555555;
  --c-divider: #a3a3a3;
  --c-divider-hi: #fdfdfd;

  /* buttons */
  --c-btn: #8b8b8b;
  --c-btn-hi: #c6c6c6;
  --c-btn-lo: #4a4a4a;
  --c-btn-hover: #9a9a9a;
  --c-btn-hover-hi: #d6d6d6;

  /* recessed dark fields */
  --c-field: #2f2f2f;
  --c-field-shadow: #000000;
  --c-field-hi: #4f4f4f;
  --c-field-ink: #e9f6df;
  --c-field-muted: #8aa97c;

  /* ink on gray panels */
  --c-ink: #2b2b2b;
  --c-ink-soft: #515151;
  --c-ink-faint: #6a6a6a;
  --c-steps: #3a3a3a;
  --c-status-online: #1f3d12;
  --c-status-offline: #4a1410;
  --c-dot-idle: #6b6b6b;

  /* player list (in-game tab list) */
  --c-list: rgba(12, 14, 22, 0.86);
  --c-list-hi: #2a2f42;
  --c-list-lo: #05060a;
  --c-list-ink: #eef1f7;
  --c-list-deco: #6b7390;
  --c-list-sub: #aab0c4;
  --c-list-row: rgba(255, 255, 255, 0.045);
  --c-list-row-hover: rgba(255, 255, 255, 0.10);
  --c-online: #5fd152;

  /* text on dark chrome */
  --c-on-dark: #ffffff;
  --c-foot: #b8a98c;
  --c-foot-sep: #5a4a30;
  --c-link: var(--c-grass-hi);

  /* ---------- type ---------- */
  --font-pixel: "Monocraft", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* integer px keeps the pixel font from blurring on fractional sizes */
  --fs-brand: 28px;
  --fs-title: 20px;
  --fs-btn: 18px;
  --fs-btn-sm: 16px;
  --fs-status: 16px;
  --fs-version: 15px;
  --fs-motd: 17px;
  --fs-field: 18px;
  --fs-tag: 12px;
  --fs-list: 17px;
  --fs-list-head: 16px;
  --fs-list-sub: 14px;
  --fs-foot: 13px;
  --fs-body: 16px;

  /* ---------- metrics ---------- */
  --outline: 3px;                /* panel / button outer border */
  /* on-screen block size: the world slice is COLS=36 wide under background:cover,
     so one block == 100vw/36. Header dirt + footer bedrock share this grid. */
  --tile: calc(100vw / 36);
  --maxw: 920px;
  --pad-panel: 20px;
  --gap: 12px;
  --shadow-text: 2px 2px 0 #000;
  --shadow-text-soft: 1px 1px 0 #000;

  /* ---------- composite bevels (the GUI 9-slice) ---------- */
  --bevel-panel: inset 3px 3px 0 var(--c-panel-hi), inset -3px -3px 0 var(--c-panel-lo);
  --bevel-btn: inset 2px 2px 0 var(--c-btn-hi), inset -2px -2px 0 var(--c-btn-lo);
  --bevel-btn-hover: inset 2px 2px 0 var(--c-btn-hover-hi), inset -2px -2px 0 var(--c-btn-lo);
  --bevel-btn-press: inset -2px -2px 0 var(--c-btn-hi), inset 2px 2px 0 var(--c-btn-lo);
  --bevel-field: inset 2px 2px 0 var(--c-field-shadow), inset -2px -2px 0 var(--c-field-hi);
  --bevel-pill: inset 2px 2px 0 #373737, inset -2px -2px 0 #e4e4e4;
  --bevel-list: inset 2px 2px 0 var(--c-list-hi), inset -2px -2px 0 var(--c-list-lo);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: #e9e4da;
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  line-height: 1.5;
}

/* world-slice backdrop — a real-texture cross-section of the world fills the
   page: dirt under the grass bar, then stone, deepslate, ore veins, caves,
   lava and bedrock down deep (built from Minecraft tiles by
   web/tools/build-world-tex.py -> assets/tex/world.png). */
body::before,
body::after { content: ""; position: fixed; inset: 0; pointer-events: none; }
body::before {
  z-index: -2;
  background-color: var(--c-strata-bedrock);
  background-image: url("tex/world.png?v=7");
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
/* scrim: a soft vignette so the GUI panels read against the bright stone, plus
   a warm lava glow welling up from the deep. */
body::after {
  z-index: -1;
  background-image:
    radial-gradient(130% 95% at 50% 6%, transparent 62%, var(--c-depth-shade) 100%),
    radial-gradient(46% 20% at 50% 103%, var(--c-lava-glow), transparent 74%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

a { color: var(--c-link); }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--c-grass); color: #06210a; padding: 8px 14px; z-index: 50;
}
.skip:focus { left: 0; }

/* a reusable "pixel text" baseline */
.pixel,
.brand-name, .mc-btn, .mc-panel__title, .join-title, .status-pill, .version, .motd,
.field, .field-tag, .pl-title, .pl-top, .pl-row, .pl-empty, .foot {
  font-family: var(--font-pixel);
  -webkit-font-smoothing: none;
  font-smooth: never;
}

/* ---------- shared GUI bevels ---------- */
.mc-panel,
.mc-frame {
  background: var(--c-panel);
  border: var(--outline) solid var(--c-line);
  box-shadow: var(--bevel-panel);
}

/* ---------- pixel buttons ---------- */
.mc-btn {
  font-size: var(--fs-btn);
  line-height: 1;
  color: var(--c-on-dark);
  text-shadow: 2px 2px 0 #3f3f3f;
  background: var(--c-btn);
  border: var(--outline) solid var(--c-line);
  box-shadow: var(--bevel-btn);
  padding: 14px 22px;
  cursor: pointer;
  user-select: none;
}
.mc-btn:hover,
.mc-btn:focus-visible {
  background: var(--c-btn-hover);
  color: var(--c-gold);
  outline: none;
  box-shadow: var(--bevel-btn-hover), 0 0 0 2px #fff;
}
.mc-btn:active {
  box-shadow: var(--bevel-btn-press);
  transform: translateY(1px);
}
.mc-btn.sm { font-size: var(--fs-btn-sm); padding: 11px 16px; }

/* ---------- top bar: grass-block edge ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(14px, 4vw, 40px);
  background-color: var(--c-dirt-solid);
  background-image: url("tex/header.png"), url("tex/dirt.png");
  background-position: top left, top left;
  background-size: var(--tile) var(--tile), var(--tile) var(--tile);
  background-repeat: repeat-x, repeat;
  image-rendering: pixelated;
  /* soft shadow cast down onto the world slice — depth without a hard black bar */
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.5);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-block {
  width: 38px; height: 38px;
  background: var(--c-dirt-solid) url("tex/header.png") top center / 100% auto repeat-x;
  border: var(--outline) solid var(--c-line);
  image-rendering: pixelated;
}
.brand-name {
  font-size: var(--fs-brand);
  color: var(--c-on-dark);
  text-shadow: var(--shadow-text);
  letter-spacing: .5px;
}
.tabs { display: flex; gap: 8px; }
.tab[aria-selected="true"] {
  color: var(--c-gold);
  box-shadow: var(--bevel-btn-press);
}

/* ---------- layout ---------- */
.panel { display: none; }
.panel.is-active { display: block; }
main { flex: 1; }
.stack {
  max-width: var(--maxw);
  margin: clamp(24px, 5vw, 56px) auto;
  padding: 0 clamp(12px, 4vw, 24px);
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(16px, 2.5vw, 24px);
}
@media (max-width: 820px) { .stack { grid-template-columns: 1fr; } }

/* ---------- GUI panels ---------- */
.mc-panel { padding: 0; }
.mc-panel__title {
  font-size: var(--fs-title);
  color: var(--c-ink);
  margin: 0;
  padding: 15px 20px 13px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: var(--outline) solid var(--c-divider);
  box-shadow: 0 3px 0 var(--c-divider-hi);
}
.mc-panel__body { padding: var(--pad-panel); color: var(--c-ink); }

/* status line */
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-status); color: var(--c-ink);
  background: #b0b0b0;
  border: 2px solid var(--c-line);
  box-shadow: var(--bevel-pill);
  padding: 8px 13px;
}
.status-pill .dot {
  width: 12px; height: 12px; background: var(--c-dot-idle);
  box-shadow: 0 0 0 2px #00000033;
  image-rendering: pixelated;
}
.status-pill[data-state="online"] .dot { background: var(--c-grass); box-shadow: 0 0 6px var(--c-grass-hi); }
.status-pill[data-state="online"] { color: var(--c-status-online); }
.status-pill[data-state="offline"] .dot { background: var(--c-redstone); }
.status-pill[data-state="offline"] { color: var(--c-status-offline); }
/* version tag — a small gray GUI chip matching the status pill */
.version {
  margin-left: auto;
  font-size: var(--fs-version); line-height: 1; color: var(--c-ink);
  background: #b0b0b0;
  border: 2px solid var(--c-line);
  box-shadow: var(--bevel-pill);
  padding: 7px 11px;
}
.motd { margin: 14px 0 18px; font-size: var(--fs-motd); color: var(--c-steps); min-height: 1.2em; }

/* address fields */
.addresses { display: flex; flex-direction: column; gap: 10px; }
.field-row { display: flex; align-items: center; gap: 10px; }
.field-tag {
  font-size: var(--fs-tag); color: var(--c-on-dark);
  padding: 5px 8px; border: 2px solid var(--c-line);
  text-shadow: var(--shadow-text-soft); flex: none;
}
.field-tag.java { background: var(--c-grass); }
.field-tag.bedrock { background: var(--c-amber); }
/* address field — sized to match the .mc-btn.sm beside it (same font, line-height,
   padding and border => identical box height) */
.field {
  flex: 1 1 auto;
  font-size: var(--fs-btn-sm); line-height: 1; color: var(--c-field-ink);
  background: var(--c-field);
  border: var(--outline) solid var(--c-line);
  box-shadow: var(--bevel-field);
  padding: 11px 16px;
  text-shadow: var(--shadow-text);
  overflow: auto; white-space: nowrap;
}
.field .muted { color: var(--c-field-muted); }
.copy.copied { color: #06210a; background: var(--c-grass); }

/* ---------- player list — the in-game tab list, standalone (no GUI wrapper) ---------- */
.playerlist {
  background: var(--c-list);
  border: var(--outline) solid var(--c-line);
  box-shadow: var(--bevel-list);
  padding: 14px 16px 16px;
}
.pl-title {
  text-align: center; font-size: var(--fs-title); color: var(--c-bedrock);
  text-shadow: var(--shadow-text); margin-bottom: 8px;
}
.pl-top {
  display: flex; justify-content: center; align-items: baseline; gap: 8px;
  font-size: var(--fs-list-head); color: var(--c-list-sub);
  margin-bottom: 12px; padding-bottom: 12px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}
.pl-deco { color: var(--c-list-deco); }
.pl-count { color: var(--c-on-dark); }
.pl-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pl-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 8px;
  font-size: var(--fs-list); color: var(--c-list-ink);
  background: var(--c-list-row);
}
.pl-row:hover { background: var(--c-list-row-hover); }
.pl-head { width: 22px; height: 22px; image-rendering: pixelated; flex: none; background: #0003; }
.pl-name { text-shadow: var(--shadow-text-soft); }
.pl-name.bedrock { color: var(--c-bedrock); }
.pl-be { color: var(--c-bedrock); margin-left: 5px; }
.pl-bars { margin-left: auto; display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; flex: none; }
.pl-bars i { width: 3px; background: var(--c-online); display: block; }
.pl-bars i:nth-child(1) { height: 5px; }
.pl-bars i:nth-child(2) { height: 8px; }
.pl-bars i:nth-child(3) { height: 11px; }
.pl-bars i:nth-child(4) { height: 15px; }
.pl-row.pl-more { justify-content: center; color: var(--c-list-deco); }
.pl-empty {
  text-align: center; color: var(--c-list-sub);
  font-size: var(--fs-list-sub); margin: 8px 0 2px;
}

/* ---------- how to join (below the address, same panel) ---------- */
.join {
  margin-top: 20px; padding-top: 16px;
  border-top: var(--outline) solid var(--c-divider);
}
.join-title { font-size: var(--fs-title); color: var(--c-ink); margin: 0 0 10px; }
.steps { margin: 0; padding-left: 20px; color: var(--c-steps); font-size: var(--fs-body); line-height: 1.7; }
.steps strong { color: var(--c-ink); }
.steps code,
.mc-panel__body code:not(.field) {
  font-family: var(--font-pixel); -webkit-font-smoothing: none; font-size: 0.85em;
  background: var(--c-field); color: var(--c-field-ink);
  border: 2px solid var(--c-line);
  padding: 1px 6px; text-shadow: var(--shadow-text-soft);
}

/* ---------- map ---------- */
/* fill the viewport exactly (no page scroll): on the map tab make main a flex
   column and let the frame flex into the leftover height instead of guessing the
   chrome height with a magic number (topbar + footer + margins ≈ 175px, not 150). */
html[data-tab="map"] main { display: flex; flex-direction: column; min-height: 0; }
.panel-map.is-active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mc-frame.map-frame {
  flex: 1; min-height: 0; margin: clamp(10px, 2vw, 18px); position: relative;
  padding: 0; background: #0c0f0a;
}
/* absolute fill — height:100% won't resolve through the flex chain */
.map-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0c0f0a; }

/* ---------- footer ---------- */
.foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
  padding: 16px;
  font-size: var(--fs-foot); color: var(--c-foot);
  /* bedrock floor: real tile, darkened a touch so the text stays legible */
  background:
    linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),
    url("tex/bedrock.png") top left / var(--tile) var(--tile) repeat,
    var(--c-strata-bedrock);
  image-rendering: pixelated;
  border-top: var(--outline) solid var(--c-line);
  text-shadow: var(--shadow-text);
}
.foot a { color: var(--c-link); text-decoration: none; }
.foot a:hover { color: var(--c-gold); }
.foot-sep { color: var(--c-foot-sep); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
