/* Theme tokens */
:root{
  --bg-color: #0e0f11;        /* page background color */
  --card: #16171a;
  --text: #f4f6f8;
  --muted: #a2a7b0;
  --ring: #2a2d34;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);

  /* unified height for inputs & buttons */
  --controlH: 44px;
}

*{box-sizing:border-box}
html,body{height:100%}

/* Keep layout stable: prevent scrollbar from popping in/out */
html{ scrollbar-gutter: stable; }
body{
  overflow-y: scroll;
  margin:0;
  background:var(--bg-color);
  color:var(--text);
  font:16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

/* Page width similar to DonutSMP */
.wrap{max-width:1280px; margin:0 auto; padding:40px;}

.grid{
  display:grid;
  gap:24px;
  grid-template-columns: minmax(280px, 340px) 1fr minmax(280px, 340px);
  /* equal row heights so bottom row matches top row */
  grid-template-rows: 300px 300px;
  grid-template-areas:
    "logo store discord"
    "stats join  join";
}

.card{
  position:relative;
  display:block;
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
  outline:1px solid var(--ring);
  transform:translateZ(0);
  transition:transform .2s ease, outline-color .2s ease;
  text-decoration:none;
  color:inherit;
  cursor:inherit;
}
.card:hover{ transform:scale(1.02); outline-color:#3b82f6; }

/* Media background (uses an image var to avoid clashes with colors) */
.media{
  position:absolute; inset:0;
  background-image: var(--media-bg, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter:saturate(1.1);
}
.media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.15));
}

/* shared labels */
.label{
  position:absolute; top:16px; left:16px;
  background:rgba(0,0,0,.5);
  backdrop-filter:saturate(130%) blur(4px);
  padding:10px 14px; border-radius:14px;
  font-weight:800; letter-spacing:.3px;
  text-transform:capitalize;
}

/* footer for logo/IP card */
.card--logo{ grid-area:logo; }
.card--logo .footer{
  position:absolute; inset:auto 0 0 0;
  display:flex; align-items:center; justify-content:space-between;
  gap:10px;
  padding:16px 18px;
  background:linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.65) 60%);
  font-weight:800;
}
.card--logo .footer-left{ display:flex; align-items:center; gap:10px; }
.card--logo .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.card--logo .media { --media-bg: url('assets/chumbucket.png'); }

/* map card */
.card--store .media {
  --media-bg: url('assets/map.png'); /* make sure assets/map.png exists */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}


/* USER PILL — top-right of the card */
.user-pill{
  position:absolute;
  top:14px;
  right:14px;
  display:inline-flex;
  align-items:center;
  gap:10px;
  background:rgba(0,0,0,.55);
  border:1px solid rgba(255,255,255,.2);
  padding:8px 12px;
  border-radius:999px;
  backdrop-filter: saturate(130%) blur(4px);
  white-space:nowrap;
  z-index:5;
}
.user-pill img{ border-radius:6px; width:28px; height:28px; image-rendering: pixelated; }
.pill-name{ font-weight:800; font-size:14px; }
.pill-link{
  background:transparent; border:0; color:#60a5fa;
  font-size:13px; font-weight:800; cursor:pointer; padding:0;
}
.pill-link:hover{ text-decoration: underline; }

/* discord card */
.card--discord{ grid-area:discord; display:flex; align-items:center; justify-content:center; }
.card--discord .discord{ display:flex; flex-direction:column; align-items:center; gap:16px; }
.card--discord .big{ font-weight:900; font-size:32px; line-height:1; }
.card--discord .small{ color:var(--muted); font-weight:700; }

/* stats */
.card--stats{ grid-area:stats; cursor:pointer; }
.card--stats .label{ left:18px; top:18px; }
.card--stats .media { --media-bg: url('assets/stats.png'); background-size: cover; }

/* join card */
.card--join{ grid-area:join; }
.card--join .join{
  position:absolute; right:24px; bottom:24px;
  width:min(380px, 92%);
  display:grid; gap:10px;
  background:rgba(0,0,0,.55);
  padding:14px; border-radius:16px;
  backdrop-filter: blur(6px);
}
.card--join label{ display:grid; gap:6px; font-weight:700; }

/* unified heights for controls */
.card--join input{
  width:100%;
  height: var(--controlH);
  padding: 0 12px;
  border-radius:12px;
  border:1px solid var(--ring);
  background:#0f1114;
  color:var(--text);
  font-size:14px;
}
.card--join button{
  height: var(--controlH);
  padding: 0 16px;
  border-radius:12px; border:0; cursor:pointer;
  background:#3b82f6; color:white; font-weight:800; font-size:14px;
  display:inline-flex; align-items:center; justify-content:center;
}

/* ✅ FIXED: better framing for the How To Join image */
.card--join .media {
  --media-bg: url('assets/howto.png');
  background-size: cover;
  background-position: center 25%;
  background-repeat: no-repeat;
}

/* --- Panels under grid --- */
.embed-container{
  grid-column: 1 / -1;
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
  outline:1px solid var(--ring);

  /* default/fallback embed height */
  --embedH: 1040px;

  --origin: top;
  transform-origin: var(--origin);
  max-height: 0;
  opacity: 0;
  transform: scaleY(0.98);
  transition: max-height 900ms ease, opacity 900ms ease, transform 900ms ease;
  will-change: max-height, opacity, transform;
  margin-top: 16px;
}

.embed-container.open{
  max-height: var(--embedH);
  opacity: 1;
  transform: scaleY(1);
}

.embed-container iframe{
  width:100%;
  height:var(--embedH);
  border:0;
  display:block;
}

/* ✅ Consistency check: per-panel overrides */
#mapSection   { --embedH: 1040px; }
#statsSection { --embedH: 860px; }
#blogSection  { --embedH: 720px; }

/* responsive */
@media (max-width: 1200px){
  .wrap{ max-width:100%; padding:36px; }
  .grid{
    grid-template-columns: minmax(260px, 320px) 1fr minmax(260px, 320px);
    grid-template-rows: 280px 280px;
    gap:22px;
  }
  .embed-container{ --embedH: 860px; margin-top: 14px; }
  #mapSection   { --embedH: 860px; }
  #statsSection { --embedH: 720px; }
  #blogSection  { --embedH: 640px; }
}
@media (max-width: 980px){
  .wrap{ padding:28px; }
  .grid{
    grid-template-columns: 1fr;
    grid-template-rows: repeat(5, 280px);
    grid-template-areas:
      "logo"
      "store"
      "discord"
      "stats"
      "join";
  }
  .card--join .join{ position:static; width:100%; margin:16px; }
  .embed-container{ --embedH: 720px; margin-top: 14px; }
  #mapSection   { --embedH: 720px; }
  #statsSection { --embedH: 600px; }
  #blogSection  { --embedH: 520px; }
}
@media (max-width: 520px){
  .wrap{ padding:20px; }
  .grid{ gap:18px; grid-template-rows: repeat(5, 240px); }
  .embed-container{ --embedH: 520px; margin-top: 12px; }
  #mapSection, #statsSection, #blogSection { --embedH: 480px; }
}

/* Blog/Map/Stats header + content */
.blog-header {
  background: rgba(0,0,0,0.6);
  padding: 16px;
  border-bottom: 1px solid var(--ring);
}
.blog-header h1 { margin: 0; font-size: 28px; font-weight: 900; }
.blog-content { padding: 20px; font-size: 16px; line-height: 1.6; }
.blog-content h2 { font-size: 20px; margin-top: 0; }

/* ---------- Username Gate Overlay ---------- */
.gate{
  position: fixed;
  inset: 0;
  min-height: 100dvh;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px) saturate(120%);
  display: grid;
  place-items: center;
  z-index: 9999;
}
body.gating { overflow: hidden; }
body.gating #pageMain { pointer-events:none; user-select:none; }

.gate-card{
  width: min(400px, 92vw);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  outline: 1px solid var(--ring);
  padding: 26px 24px 22px;
  display: grid;
  gap: 14px;
}
.gate-label{ font-weight: 700; margin-bottom: 6px; }

#gateForm{ display:grid; gap:14px; }
#gateForm input[type="text"]{
  width:100%;
  height: var(--controlH);
  padding: 0 12px;
  border-radius:12px;
  border:1px solid var(--ring);
  background:#0f1114;
  color:var(--text);
  font-size:15px;
}
#gateForm input[type="text"]::placeholder{ color: var(--muted); }

#saveNameBtn{
  height: var(--controlH);
  padding: 0 16px;
  border-radius:12px;
  border:0;
  cursor:pointer;
  background:#3b82f6;
  color:white;
  font-weight:800;
  font-size:14px;
  display:inline-flex; align-items:center; justify-content:center;
  transition: background .2s ease;
}
#saveNameBtn:hover{ background:#2563eb; }
#saveNameBtn[disabled]{ opacity:.6; cursor:progress; }

.error{ color:#f87171; font-weight:700; min-height:1.2em; text-align:center; }
