/* public/css/base.css
   Minimal, modern, centered layout and readable typography
   Responsive images and admin table improvements
*/

:root{
  --max-width: 980px;
  --content-padding: 20px;
  --bg: #f6f7f9;
  --card-bg: #ffffff;
  --muted: #666;
  --accent: #1a73e8;
  --accent-2: #e03b3b; /* chili red */
  --hero-overlay: rgba(6,20,12,0.28);
  --header-h: 110px; /* tuned header height so hero content sits clearly below the fixed header */
  --header-h-mobile: 72px; /* mobile header height for padding calculations */
  --hero-offset: 22px; /* comfortable visual gap between header and hero content */
    --header-h: 110px; /* tuned header height so hero content sits clearly below the fixed header; overridden by runtime JS */
    --header-h-mobile: 72px; /* mobile header height for padding calculations */
    --hero-offset: 20px; /* comfortable visual gap between header and hero content */
  --border: #e9eef3;
  --radius: 8px;
  --text: #222;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace;
  /* Vote button sizing defaults; page JS may override --vote-size-from-meme */
  --vote-size-desktop: 180px;
  --vote-size-mobile-min: 88px;
  --vote-size-from-meme: var(--vote-size-desktop);
}

* { box-sizing: border-box; }

html,body { height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  line-height:1.45;
  font-size:16px;
}

/* Page frame */
.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(10,10,10,0.02);
}
.site-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(var(--content-padding) * 1.2);
}

.header-inner {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}

.brand {
  display:inline-flex;
  align-items:center;
  gap:10px;
  font-weight:700;
  font-size:1rem; /* base for the brand text */
  color:var(--text);
  text-decoration:none;
  flex: 0 0 auto;
}
.brand-logo {
  height: 3.6rem;
  width: auto;
  object-fit: contain;
  display: inline-block;
  max-height: 3.6rem;
}
.header .brand-logo { /* ensure consistent logo size regardless of page-specific context */
  height: 3.6rem;
  max-height: 3.6rem;
  width: auto;
}
.brand-text { font-weight:700; font-size:3rem; line-height:1; color:var(--text); text-decoration:none; }
.brand small { color:var(--muted); font-weight:400; margin-left:8px; font-size:0.9rem; }

/* Navigation */
.nav {
  display:flex;
  gap:8px;
  align-items:center;
  font-size:0.95rem;
  flex: 1 1 auto;
  justify-content: flex-end; /* push nav items to the right; Upload will appear left-most inside the nav */
}
.nav a { flex: 0 1 auto; min-width:0; }
.nav a { color: var(--accent); text-decoration:none; padding:6px 8px; border-radius:6px; }
.nav a:hover { background: rgba(26,115,232,0.06); }
.nav .cta, .primary-cta {
  background: linear-gradient(90deg,var(--accent-2), #ff7a4d);
  color: #fff;
  padding:8px 14px;
  border-radius:10px;
  font-weight:700;
  text-decoration:none;
  box-shadow: 0 8px 20px rgba(224,59,59,0.14);
}
.nav .cta:hover, .primary-cta:hover { opacity:0.95; transform:translateY(-1px); }

/* hide navigation on homepage for distraction-free landing */
body.home .nav { display:none; }
/* make header transparent and overlay the hero */
/* Header: fixed and consistent placement across all pages. On the home page it is transparent so the hero image shows through. */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(6,10,12,0.06);
}
.header-inner { padding: 10px 0; }
body.home .header { background: transparent; border-bottom: none; box-shadow: none; }

/* visually separate the brand/logo on the homepage so transparent parts
   of the image don't show the hero behind it. Keeps the header transparent
   but gives the logo a neutral pill behind it for legibility. */
body.home .brand {
  background: rgba(255,255,255,0.94);
  padding: 6px 8px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(6,10,12,0.06);
}
body:not(.home) .brand { background: transparent; padding: 0; }
/* create a slightly larger backdrop behind the brand so rounded corners
   never reveal the hero image underneath (prevents visible bleed on
   narrow viewports / small gaps). The ::before is positioned behind the
   brand and expands slightly to cover any rounded-corner artifacts. */
body.home .brand { position: relative; z-index: 1001; }
body.home .brand::before {
  content: '';
  position: absolute;
  left: -6px;
  top: -6px;
  right: -6px;
  bottom: -6px;
  background: rgba(255,255,255,0.94);
  border-radius: 12px;
  z-index: -1;
}

/* make space for the fixed header on pages where it should not overlay content */
body.home main { padding-top: 0; }
/* Tighten default top spacing under the fixed header across pages */
body:not(.home) main { padding-top: 84px; }
@media (max-width: 900px) {
  body:not(.home) main { padding-top: 64px; }
}
/* Reduce top padding on meme pages to remove dead zone under header */
/* Meme page: slightly tighter than default */
/* Remove extra top padding for meme pages; place card precisely under header */
body.meme-page main { padding-top: 0 !important; }
/* nudge the card below the header using the runtime header height so there's no large dead gap */
.meme-page .meme-card { margin-top: calc(var(--header-h, 64px) - 8px); }
@media (max-width: 900px) {
  body.meme-page main { padding-top: 56px; }
}

/* Settings page: align spacing similar to meme page to remove dead zone */
body.settings-page main { padding-top: 64px; }
@media (max-width: 900px) {
  body.settings-page main { padding-top: 56px; }
}

/* Hero grid layout */
.hero-grid { display:grid; grid-template-columns: 1fr 480px; gap:28px; align-items:center; }
.hero-copy { color:#fff; }
.hero-copy h1 { font-size:2.6rem; margin:0 0 10px 0; color: #fff; }
.hero-copy .lead { font-size:1.1rem; color: rgba(255,255,255,0.92); margin-bottom:18px; }
.hero-cta-row { display:flex; gap:12px; align-items:center; margin-bottom:16px; }
.ghost-cta { padding:8px 12px; border-radius:8px; text-decoration:none; background: rgba(255,255,255,0.08); color:#fff; border:1px solid rgba(255,255,255,0.08); }
.ghost-cta:hover { background: rgba(255,255,255,0.12); }
.trust-row { display:flex; gap:18px; margin-top:8px; }
.trust-item { text-align:left; color:#fff; }
.trust-item strong { display:block; font-size:1.05rem; }

.hero-media { height: 320px; border-radius:12px; background-image: url('/assets/red-green.jpg'); background-size: cover; background-position: center; box-shadow: 0 20px 50px rgba(0,0,0,0.32); }
.social-proof { margin-top: 18px; color: rgba(255,255,255,0.95); }
.social-proof blockquote { margin:0; background: rgba(0,0,0,0.22); padding:12px 16px; border-radius:8px; }
.social-proof cite { display:block; margin-top:8px; color: rgba(255,255,255,0.8); font-size:0.9rem; }

/* center brand on small screens */
@media (max-width:720px) {
  .hero-grid { grid-template-columns: 1fr; }
  /* keep header alignment consistent across pages (logo stays top-left) */
  /* keep brand visible on small screens but scale down */
  .brand-text { font-size:1.6rem; }
  /* make the logo occupy a meaningful portion of the header on narrow viewports
     while allowing nav items to shrink. Use viewport width-based sizing but cap it. */
  .brand-logo { width: clamp(48px, 25vw, 120px); height: auto; max-height: 3.2rem; }
  .nav { gap:6px; }
  .nav a { padding:6px 8px; font-size:0.92rem; }
  .hero-media { height:240px; }
  .home-hero-inner { padding: 28px 18px; }
  .hero-copy h1 { font-size:1.6rem; }
}

/* Main */
main {
  min-height: calc(100vh - 160px);
  padding-top: 12px;
  padding-bottom: 18px;
}

/* Homepage hero */
.home-hero {
  min-height: calc(100vh - 120px);
  display:flex;
  align-items:flex-start; /* align content below the header */
  background-image: url('/assets/red-green.jpg');
  background-size: cover;
  background-position: center top;
  color: #fff;
  padding-top: calc(var(--header-h) + var(--hero-offset)); /* push hero content down so header/logo do not overlap */
}
.home-hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
  text-align: left;
  /* keep inner container transparent so the hero photo shows naturally */
  backdrop-filter: none;
  background: transparent;
  border-radius: 12px;
  margin-top: 24px; /* increased gap from the header for better separation */
}
/* improve legibility on varied hero photos */
.home-hero h1 { text-shadow: 0 2px 10px rgba(0,0,0,0.45); }
.home-hero .lead { text-shadow: 0 1px 6px rgba(0,0,0,0.35); }
/* stray rule removed: ensure brand-logo size comes only from header-scoped rules */
.home-hero h1 { font-size: 2.4rem; margin-bottom: 12px; color: #fff; }
.home-hero .lead { font-size:1.1rem; color: rgba(255,255,255,0.92); margin-bottom:18px; }
.primary-cta { display:inline-block; }

@media (max-width:640px) {
  /* On very small screens allow the logo to shrink but keep a minimum size. */
  .brand-logo { width: clamp(36px, 22vw, 88px); height: auto; }
  /* on small screens reduce the hero top padding so content isn't pushed too far down */
  .home-hero { padding-top: calc(var(--header-h-mobile) + (var(--hero-offset) - 6px)); }
  .home-hero-inner { padding: 28px 14px; margin-top: 16px; }
  .home-hero h1 { font-size:1.5rem; }
}

/* Headings */
h1 { margin: 0 0 8px 0; font-size:1.6rem; line-height:1.15; }
h2 { margin: 0 0 10px 0; font-size:1.25rem; }

/* Content card */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 6px 18px rgba(15,20,30,0.02);
}

/* Form helpers */
form { margin: 0; }
input[type="file"], input[type="text"], textarea, select {
  font-size:1rem;
  padding:8px 10px;
  border-radius:6px;
  border:1px solid #dfe7ee;
  width:100%;
  background:white;
}

/* Images */
img { max-width:100%; height:auto; display:block; }

/* meme frame images and thumbnails */
.meme-grid {
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items:start;
}
.meme-card {
  background:var(--card-bg);
  border-radius:8px;
  overflow:hidden;
  border: 1px solid var(--border);
}
.meme-card img { display:block; width:100%; height:160px; object-fit:cover; }

/* Admin table */
.table-wrap { overflow-x:auto; }
.admin-table {
  width:100%;
  border-collapse:collapse;
  font-size:0.95rem;
  min-width:720px;
}
.admin-table th, .admin-table td {
  padding: 10px 12px;
  border-bottom:1px solid #f1f5f8;
  vertical-align: middle;
  text-align: left;
}
.admin-table th {
  background: #fafbfd;
  color: #334;
  font-weight:600;
  font-size:0.9rem;
  letter-spacing: .01em;
}
.thumb {
  width:120px;
  height:80px;
  object-fit:cover;
  border-radius:6px;
  display:block;
  border:1px solid #ecf0f3;
}

/* badges */
.badge {
  display:inline-block;
  padding:4px 8px;
  border-radius:6px;
  font-size:12px;
  color:#213;
  background:#f2f7f3;
  margin-right:6px;
}
.badge.missing { background:#fff1f1; color:#8a1f1f; }
.badge.ok { background:#e9f8ee; color:#1f7a1f; }

/* small muted text */
.muted { color:var(--muted); font-size:0.9rem; }

/* Footer */
.footer {
  padding: 18px 0;
  text-align:center;
  color:var(--muted);
  font-size:0.9rem;
}

/* ===== Fresh page specific styles ===== */
.fresh-meme {
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:18px;
  min-height:50vh;
}

.fresh-meme .meme-image {
  width: auto;
  max-width: 100%;
  height: 50vh;        /* image takes ~50% of viewport height */
  object-fit: contain;
  border-radius:8px;
  border:1px solid var(--border);
  background: #fff;
}

.vote-row {
  display:flex;
  justify-content:space-between;
  gap:16px;
  width:100%;
  max-width:720px;
  align-items:center;
}

/* Big buttons: left = stale, right = spicy */
.vote-btn {
  flex:1 1 50%;
  padding:14px 18px;
  border-radius:10px;
  font-size:1.05rem;
  font-weight:600;
  cursor:pointer;
  border:1px solid #dfe7ee;
  background:#fff;
}
.vote-btn.stale { background:#f7fbff; color:#0b5cff; }
.vote-btn.spicy { background:#fff7f2; color:#c33; border-color:#ffd6cf; }

/* ===== scoville badges ===== */
.scov-green { background:#e9f8ee; color:#0b6b2a; }   /* low */
.scov-red   { background:#fff4f2; color:#b02a2a; }   /* bird's eye / spicy */
.scov-yellow{ background:#fffbea; color:#7a5a00; }   /* habanero */
.scov-ghost { background:#f6f7fb; color:#6f2b8f; }   /* ghost pepper */
.scov-weapon{ background:#1a1a1a; color:#fff; }      /* weapons grade */

/* On small screens stack buttons vertically */
@media (max-width:640px) {
  .site-container { padding: 14px; }
  .thumb { width:96px; height:64px; }
  h1 { font-size:1.25rem; }
  .vote-row { flex-direction:column; gap:10px; }
  .vote-btn { width:100%; }
}

/* ===== fresh: previous tiny thumbnail and detail styles ===== */
.prev-small {
  position: fixed;
  left: 14px;
  bottom: 18px;
  width: calc(100vh / 16); /* approx 1/16th of viewport height */
  height: calc(100vh / 16);
  display:block;
  border-radius:6px;
  overflow:hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.06);
  z-index: 1200;
}
.prev-small img { width:100%; height:100%; object-fit:cover; display:block; }
.card.fresh-meme { overflow: visible; }

/* Nav toggle for narrow viewports */
.nav-toggle {
  display: none;
  background: transparent;
  border: 0;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text);
  padding: 6px 8px;
}

/* On very small screens hide the inline nav and show the toggle; when opened the nav becomes a simple stacked list. */
@media (max-width:640px) {
  .nav { display: none; position: absolute; right: 12px; top: calc(var(--header-h-mobile) + 12px); flex-direction: column; gap: 8px; z-index: 1100; }
  .nav.open { display: flex; }
  .nav a { display:block; padding: 8px 10px; border-radius:6px; background: transparent; }
  .nav a.cta { padding:8px 10px; }
  .nav-toggle { display:inline-flex; }
}

/* ===== Tiny Fresh page tweaks requested: slightly taller header, small spacing adjustments, responsive button sizing and cursor pointer ===== */
/* Slightly increase the fresh page header height so it matches /spicy and /upload.
   Compute header height from the logo so it stays consistent if logo size changes. */
body.fresh-single { --header-h: calc(3.6rem + 20px); }
/* Use the same vertical padding as other pages so visuals match exactly */
body.fresh-single .header-inner { padding: 10px 0; }
/* keep logo size consistent with /spicy and /upload */
body.fresh-single .brand-logo { height: 3.6rem; max-height: 3.6rem; }
/* Make sure the fresh page content sits below the larger header */
body.fresh-single main { padding-top: var(--header-h, calc(3.6rem + 20px)); }

/* Enforce header min-height on /fresh so the bar occupies the same vertical space */
body.fresh-single header.header { min-height: var(--header-h, calc(3.6rem + 20px)); }

/* Ensure the header container on /fresh uses the same horizontal gutters as other pages */
body.fresh-single header.header .site-container.header-inner {
  padding: 10px calc(var(--content-padding) * 1.2) !important;
}

/* The nav should not carry extra vertical padding; rely on header-inner's padding */
body.fresh-single .nav { padding-top: 0; padding-bottom: 0; }

/* Make the circular vote buttons reduce proportionally with viewport height
   as well as width so they stay roughly the same relative size as the meme.
   Allow JS (fresh_single.twig) to set --vote-size-from-meme; fall back to a clamp. */
.card.fresh-meme .vote-circle {
  width: var(--vote-size-from-meme, clamp(88px, min(16vw, 22vh), 180px)) !important;
  height: var(--vote-size-from-meme, clamp(88px, min(16vw, 22vh), 180px)) !important;
  border-radius: 50% !important;
  cursor: pointer; /* show hand cursor when hovering inside the circle */
}

/* Keep the row gap responsive */
.card.fresh-meme .vote-row { gap: clamp(8px, 2vw, 24px) !important; }

