/* =========================================================
   MemeMachine - Global Styles
   Header/Nav/Footer scale via --scale (set by header.js)
   Pages are centered and responsive
   ========================================================= */

/* ---------- 1) Variables: tweak these first ---------- */
:root{
  /* JS updates these */
  --baseH: 100px;  /* set in px by header.js */
  --scale: 1;

  /* Nav / Footer original sizes (artwork px) */
  --navH: 31px;
  --footerH: 100px;

  /* Header slice base widths */
  --s3-base-w: 93;
  --tile-base-w: 57;

  /* Global page layout */
  --maxW: 1200px;
  --padX: 22px;
  --padY: 26px;

  /* Theme */
  --bgTop: #151515;
  --bgBot: #0b0b0b;
  --text: #eaeaea;

  /* Panel / card */
  --panelTop: #2a2a2a;
  --panelBot: #171717;
  --panelBorder: rgba(255,255,255,0.10);

  /* Brass look */
  --brassTop: #660000;
  --brassBot: #330000;
  --brassBorder: #ffff99;

  /* Paper inputs */
  --paperTop: #f5f1e4;
  --paperBot: #d8cfb4;
}

/* ---------- 2) Base / Reset ---------- */
*,
*::before,
*::after{ box-sizing: border-box; }

html, body{ height: 100%; }

body{
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  /* push page below fixed header + nav (scaled) */
  padding-top: calc((var(--baseH) + var(--navH)) * var(--scale));

  /* background */
  background:
    radial-gradient(circle at 15% 0%, rgba(255,255,255,.06), transparent 45%),
    radial-gradient(circle at 85% 0%, rgba(255,180,60,.07), transparent 45%),
    linear-gradient(var(--bgTop), var(--bgBot));

  overflow-x: hidden; /* avoid tiny horizontal scroll from transforms */
}

/* Links */
a{ color: inherit; text-decoration: none; }
a:hover{ filter: brightness(1.08); }

/* sr-only */
.sr-only{
  position:absolute;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);
  white-space:nowrap;border:0;
}

/* ---------- 3) Main content (centered) ---------- */
.site-main{
  max-width: var(--maxW);
  margin: 0 auto;
  padding: var(--padY) var(--padX) 80px;
  min-height: 60vh;
}

@media (max-width: 640px){
  :root{ --padX: 14px; --padY: 18px; }
}

/* Headings */
h1, h2, h3{ margin: 0 0 12px; }
p{ margin: 0 0 14px; opacity: .92; }

/* Reusable helpers */
.center{ max-width: var(--maxW); margin-left:auto; margin-right:auto; }
.stack{ display:grid; gap:14px; }

/* Static content pages: About / Terms / Privacy / Contact */
.content-page{
  max-width: 780px;
  margin: 0 auto;
  line-height: 1.6;
}
.content-page h1{ letter-spacing: 1px; }
.content-page ul{ padding-left: 18px; }
.content-page li{ margin: 6px 0; }
.content-page a{ color:#ffcc33; font-weight:800; }
.content-page a:hover{ text-decoration: underline; }

/* ---------- 5) Header (MATCHES header.js expectations) ---------- */
.site-header{
  position: fixed;
  top:0; left:0;
  width:100%;
  z-index:9999;
}

.header-outer{
  position: relative;
  width: 100%;
  height: calc(var(--baseH) * var(--scale));
  overflow: hidden;
}

/* IMPORTANT:
   header-bg stays at BASE height and is scaled via transform.
   Do NOT make height calc(baseH*scale) here or it double-scales.
*/
.header-bg{
  position: absolute;
  inset: 0;
  height: var(--baseH);
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;

  transform: scale(var(--scale));
  transform-origin: top left;

  width: 100%;
}

/* Overlay canvas stays in base coordinates and scales */
.header-ui{
  position: absolute;
  top: 0;
  left: 0;
  height: var(--baseH);

  /* JS sets this to baseW px */
  width: 0px;

  transform: scale(var(--scale));
  transform-origin: top left;

  z-index: 10;
  pointer-events: none;
}

/* slices */
.slice{
  height: 100%;
  width: auto;
  flex: 0 0 auto;
  display:block;
}

/* slice 3 fixed width */
.s3{
  flex: 0 0 calc(var(--s3-base-w) * 1px);
  min-width: calc(var(--s3-base-w) * 1px);
  height: 100%;
  width: auto;
  display: block;
}

/* slice 4 stretches + repeats
   FIX for mobile “different shade” seam:
   lock repeat tile width to exact pixels to reduce filtering artifacts.
*/
.s4{
  flex: 1 1 auto;
  min-width: calc(var(--tile-base-w) * 1px);
  height: 100%;
  width: auto;
  display: block;

  /* This makes it fill the available width without distortion */
  object-fit: fill;          /* stretches */
  object-position: left top;
}

/* gears overlay */
.gears-overlay{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 40%;
  width: auto;
  z-index: 5;
}

/* date box */
.date-box{
  position: absolute;
  left: 90px;
  top: 58px;
  width: 111px;
  height: 31px;
  background:#000;
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:14px;
  z-index: 8;
}

/* Search bar pinned */
.header-search{
  position: absolute;
  left: 0;
  top: 50px;
  z-index: 9;
  pointer-events: auto;
}

.header-search input{
  width: 284px;
  height: 26px;
  padding: 0 10px 0 30px;
  font-size: 13px;
  font-weight: 600;
  color: #111;
  background: linear-gradient(var(--paperTop), var(--paperBot));
  border: 1px solid var(--brassBorder);
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.65),
    inset 0 -1px 0 rgba(0,0,0,0.25),
    0 1px 2px rgba(0,0,0,0.35);
  outline: none;
}

.header-search::before{
  content: "⌕";
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 800;
  color: #2b1f13;
  opacity: 0.9;
  pointer-events: none;
}

/* Login button */
.login-btn{
  position: absolute;
  top: 56px;
  left: 0; /* JS sets */
  z-index: 9;

  width: 111px;
  height: 34px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;

  color: #ffffff;
  background: linear-gradient(var(--brassTop), var(--brassBot));
  border: 1px solid var(--brassBorder);
  border-radius: 3px;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.55),
    inset 0 -1px 0 rgba(0,0,0,0.25),
    0 1px 2px rgba(0,0,0,0.35);

  pointer-events: auto;
}
.login-btn:hover{ filter: brightness(1.08); }
.login-btn:active{ transform: translateY(1px); }

/* ---------- 6) Nav ---------- */
.site-nav{
  position: fixed;
  left: 0px;
  top: calc(var(--baseH) * var(--scale));
  width: 100%;
  height: calc(var(--navH) * var(--scale));
  z-index: 9998;
  overflow: hidden;
}

/* IMPORTANT: use width calc(100%/scale) because we scale the bar via transform */
.nav-inner{
  height: var(--navH);
  width: calc(100% / var(--scale));

  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 14px;

  transform: scale(var(--scale));
  transform-origin: top left;

  background: linear-gradient(#000000, #575757);
  border-top: 1px solid rgba(255,255,255,0.10);
  border-bottom: 1px solid rgba(126, 126, 126, 0.65);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -1px 0 rgba(0,0,0,0.35);
}

.nav-link{
  color: #f1f1f1;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.6px;
  text-transform: uppercase;

  padding: 6px 10px;
  border-radius: 3px;
  border: 1px solid transparent;
}
.nav-link:hover{
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.10);
}
.nav-link.is-active{
  background: rgba(255, 204, 51, 0.18);
  border-color: rgba(255, 204, 51, 0.35);
  color: #ffe7b0;
  text-shadow: 0 1px 0 rgba(0,0,0,0.7);
}

/* ---------- 7) Footer ---------- */
.site-footer{
  width: 100%;
  height: calc(var(--footerH) * var(--scale));
  margin-top: 40px;
  overflow: hidden;
}

/* like nav: build at base size then scale */
.footer-inner{
  height: var(--footerH);
  width: calc(100% / var(--scale));

  transform: scale(var(--scale));
  transform-origin: top left;

  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px 28px;
  padding: 0 20px;

  background: linear-gradient(#3a3a3a, #1f1f1f);
  border-top: 1px solid rgba(255,255,255,0.12);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -1px 0 rgba(0,0,0,0.55);
}

.footer-left{
  color: #ddd;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.footer-links{
  display: flex;
  gap: 18px;
}

.footer-links a{
  color: #f1f1f1;
  font-weight: 600;
}
.footer-links a:hover{ color: #ffcc33; }

.footer-version{
  flex-basis: 100%;
  opacity: 0.35;
  font-size: 11px;
  letter-spacing: 0.6px;
  cursor: pointer;
  user-select: none;
  text-align: center;
}

/* ---------- 8) Auth / Forms ---------- */
.auth-card{
  max-width: 520px;
  margin: 0 auto;
  background: linear-gradient(var(--panelTop), var(--panelBot));
  border: 1px solid var(--panelBorder);
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  border-radius: 10px;
  padding: 18px 18px 14px;
  color: #eee;
}

.auth-card h1{
  margin: 0 0 12px;
  font-size: 34px;
  letter-spacing: 0.6px;
}

.auth-field{
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

.auth-field label{
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.8px;
  color: #e7e7e7;
}

.auth-field input{
  height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--brassBorder);
  background: linear-gradient(var(--paperTop), var(--paperBot));
  font-weight: 700;
  color: #111;
}

.auth-btn{
  margin-top: 10px;
  height: 30px;
  padding: 0 14px;
  border-radius: 3px;
  border: 1px solid var(--brassBorder);
  background: linear-gradient(var(--brassTop), var(--brassBot));
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.auth-btn:hover{ filter: brightness(1.10); }

.auth-links{ margin-top: 12px; color: #ddd; }
.auth-links a{ color: #ffffff; font-weight: 700; }
.auth-links a:hover{ text-decoration: underline; }

.auth-errors{
  background: rgba(180,0,0,0.18);
  border: 1px solid rgba(255,80,80,0.35);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0 14px;
}

/* Vote button (kept separate) */
.vote-btn{
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--brassBorder);
  background: linear-gradient(var(--brassTop), var(--brassBot));
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0.6px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.55),
    inset 0 -1px 0 rgba(0,0,0,0.25),
    0 1px 2px rgba(0,0,0,0.35);
}
.vote-btn:hover{ filter: brightness(1.86); }
.vote-btn.is-active{
  outline: 2px solid rgba(206, 199, 180, 0.55);
  filter: brightness(1.88);
}

/* ---------- 9) Upload UI ---------- */
.upload-preview{
  margin-top: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: linear-gradient(#2a2a2a, #141414);
  border-radius: 10px;
  padding: 10px;
}

.upload-preview__meta{
  color: #ddd;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 8px;
  opacity: 0.95;
}

.upload-preview img{
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.45);
  background: #0d0d0d;
}

.upload-preview__remove{
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: #ffcc66;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.upload-preview__remove:hover{
  background: rgba(255,204,102,0.12);
  border-color: rgba(255,204,102,0.5);
}
.upload-preview__remove:active{ transform: translateY(1px); }

.drop-zone{
  position: relative;
  border-radius: 12px;
  padding: 14px;
  border: 1px dashed rgba(255,255,255,0.25);
  background: linear-gradient(#2a2a2a, #141414);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  cursor: pointer;
  user-select: none;
}

.drop-zone:focus{
  outline: 2px solid rgba(255,204,102,0.45);
  outline-offset: 2px;
}

.drop-zone__inner{
  display: grid;
  gap: 4px;
  text-align: center;
  color: #e8e8e8;
}

.drop-zone__title{
  font-weight: 900;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.drop-zone__sub{
  opacity: 0.9;
  font-weight: 700;
}

.drop-zone__hint{
  margin-top: 6px;
  opacity: 0.75;
  font-size: 12px;
}

.drop-zone.is-dragover{
  border-color: rgba(255,204,102,0.85);
  background: linear-gradient(#343434, #1a1a1a);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.10),
    0 0 0 3px rgba(255,204,102,0.18);
}

.drop-zone.has-file{
  border-style: solid;
  border-color: rgba(255,204,102,0.45);
}

.drop-zone__input{
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.client-msg{
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(180,0,0,0.16);
  color: #ffecec;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.client-msg--warn{
  background: rgba(255,204,102,0.14);
  color: #ffe9b8;
  border-color: rgba(255,204,102,0.35);
}

.client-msg a{
  color: #ffcc33;
  font-weight: 900;
}
.client-msg a:hover{ text-decoration: underline; }

.dup-card{
  display: flex;
  gap: 10px;
  align-items: center;
}

.dup-thumb{
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.45);
  background: #0d0d0d;
}

.dup-text{ display: grid; gap: 4px; }
.dup-title{ font-weight: 900; }

/* ---------- Meme grid / thumbnails ---------- */
.meme-grid{
  display: grid;
   grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 12px;
}

.meme-card{
  display: block;
  background: linear-gradient(var(--panelTop), var(--panelBot));
  border: 1px solid var(--panelBorder);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

.meme-grid .meme-card img{
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: #333333;
}

.meme-meta{ padding: 10px 12px; }

.meme-title{
  font-weight: 800;
  font-size: 14px;
  line-height: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Meme page (single meme view) ---------- */
.meme-page{
  max-width: 980px;
  margin: 0 auto;
}

.meme-head{ margin-bottom: 12px; }

.meme-title-full{
  margin: 0 0 6px;
  font-size: 34px;
  letter-spacing: 0.6px;
}

.meme-leftcol{
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.meme-byline--under{
  margin: 10px 0 0;
  text-align: left;
  opacity: 0.9;
  max-width: 100%;
}

.meme-dot{ opacity: 0.7; margin: 0 6px; }

/* Viewer wrapper */
.meme-viewer{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;

  /* fits viewport minus fixed header+nav and some breathing room */
  min-height: calc(100vh - ((var(--baseH) + var(--navH)) * var(--scale)) - 120px);

  margin: 16px auto;
}

/* Single meme card */
.meme-card--single{
  padding: 10px;
  background: linear-gradient(var(--panelTop), var(--panelBot));
  border: 1px solid var(--panelBorder);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.40);
  align-items: center;
  justify-content: center;
}
.meme-stage{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.meme-actions--side{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 120px;
}

/* Full-size image */
.meme-card--single .meme-img{
  max-width: 100%;
  max-height: calc(100vh - ((var(--baseH) + var(--navH)) * var(--scale)) - 140px);

  width: auto;
  height: auto;

  display: block;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.45);
  background: #0d0d0d;
  object-fit: contain;
}
/* Tags under buttons */
.meme-actions--side .meme-tags{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

/* Tags row under the buttons */
.meme-tags{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 980px;
}

/* Tag pill */
.meme-tag{
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  text-decoration: none;
  color: inherit;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}
.vote-form--vertical{
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch; /* buttons same width */
}

/* Vote box (no inline styles) */
.vote-box{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 14px 0 0;
}

.vote-score{
  font-weight: 900;
  font-size: 18px;
  text-align: center;
  opacity: 0.85;
}

.vote-form{ display: flex; gap: 10px; margin: 0; }
.vote-login-hint{ opacity: 0.85; }

.meme-back{ margin-top: 16px; }
.meme-back a{ color: #ffcc33; font-weight: 900; }
.meme-back a:hover{ text-decoration: underline; }

/* Prev/Next arrows */
.meme-nav{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 38px;
  font-weight: 900;
  line-height: 1;

  color: #ffcc33;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,204,51,0.35);
  border-radius: 10px;

  user-select: none;
  z-index: 5;
  opacity: 0.85;
}
.meme-nav:hover{
  opacity: 1;
  background: rgba(0,0,0,0.65);
}

/* Outside card on desktop */
.meme-nav--prev{ left: -56px; }
.meme-nav--next{ right: -56px; }

/* Move arrows inside on smaller screens */
@media (max-width: 700px){
  .meme-nav--prev{ left: 6px; }
  .meme-nav--next{ right: 6px; }
}

/* ---------- Logged-in user chip (icon + name) ---------- */
.user_chip{
  position: absolute;
  right: 100px;
  top: 2px;
  z-index: 9;
  text-align: right;

  height: 28px;
  padding: 0 5px 0 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);

  pointer-events: auto;
  user-select: none;
  white-space: nowrap;
}

.user_chip_icon{
  width: 16px;
  height: 16px;
  display: block;
  opacity: 0.9;
}

.user_chip_name{
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #f2f2f2;

  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-section{
  width: 100%;
  max-width: 100%;
  display: block;
  clear: both;
}

/* =========================================================
   MOBILE POLISH (Quick + easy)
   - Bigger nav tap targets
   - Bigger header search
   - Smaller "likes" text on cards
   - Tighter grid spacing + smaller thumbs
   ========================================================= */
@media (max-width: 768px){
 .site-main{
    padding-bottom: 40px; /* was 80px */
  }
  /* Make nav items easier to tap */
  .nav-inner{
    gap: 10px;
    padding: 0 10px;
  }
  .nav-link{
    font-size: 14px;
    padding: 8px 10px;
  }

  /* Make header search larger and easier on thumbs */
  .header-search input{
    height: 34px;
    font-size: 14px;
  }

  /* Slightly bigger user chip */
  .user_chip{
    height: 30px;
  }
  .user_chip_name{
    font-size: 13px;
  }
  /* FIX: stop forcing the viewer to be almost full-screen */
  .meme-viewer{
    min-height: 0;        /* <-- FIX */
    margin: 10px auto;    /* tighter spacing */
    padding: 0;           /* just in case */
  }

  /* FIX: reduce huge title spacing */
  .meme-title-full{
    font-size: 24px;
    margin: 0 0 8px;
  }

  /* FIX: keep the image+actions from creating tall empty columns */
  .meme-stage{
    align-items: flex-start;
  }

  /* Optional: slightly smaller image padding/card */
  .meme-card--single{
    padding: 8px;
  }
  /* Grid tighter on mobile + 2 columns */
  .meme-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  /* Smaller thumbnails so feed feels less cramped */
  .meme-grid .meme-card img{
    height: 140px;
  }

  /* Smaller title text inside cards */
  .meme-title{
    font-size: 13px;
  }

  /* Smaller vote/likes text (your cards use various labels across pages) */
  .meme-votes,
  .vote-score{
    font-size: 12px;
    padding: 4px 6px;
  }
}

.pref-saved-msg{
  font-weight: 900;
  color: #66ff99;
  opacity: 1;
  animation: fadePrefMsg 3s forwards;
}

@keyframes fadePrefMsg{
  0%   { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
