/* Paper's Here! — phone-first dense feed
   Palette: warm cream / ink / navy — paper-boy morning nostalgia */

:root {
  --cream: #f7f1e4;
  --cream-deep: #efe6d4;
  --paper: #fffdf8;
  --ink: #1c1a17;
  --ink-soft: #3d3830;
  --muted: #6b6458;
  --navy: #1a2a4a;
  --navy-deep: #0f1a30;
  --navy-mid: #2a4068;
  --gold: #b08d3e;
  --gold-soft: #d4b56a;
  --rule: #d9cbb3;
  --brown-rule: #8B6914;
  --card-shadow: 0 2px 10px rgba(26, 42, 74, 0.06);
  --radius: 8px;
  --serif: "Libre Baskerville", "Georgia", "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --max: 640px;
  --banner-h: clamp(6.25rem, 34vw, 9.5rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top, #fffaf0 0%, var(--cream) 55%, var(--cream-deep) 100%);
  min-height: 100vh;
}

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

a {
  color: var(--navy-mid);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--gold);
}

.wrap {
  width: min(100% - 1rem, var(--max));
  margin-inline: auto;
}

/* —— Extra Extra breaking strip —— */
.extra-banner {
  display: none;
  width: 100%;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cream);
  background: linear-gradient(90deg, #7a1212 0%, #b42318 50%, #7a1212 100%);
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

.extra-banner:not([hidden]) {
  display: block;
}

html.is-extra-extra .extra-banner {
  display: block;
}

/* —— Masthead / top bar (auto-hide on scroll down) —— */
.topbar {
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 253, 248, 0.96);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
  transform: translateY(0);
  transition: transform 0.28s ease, box-shadow 0.28s ease;
  will-change: transform;
}

.topbar.is-hidden {
  transform: translateY(-110%);
  box-shadow: none;
  pointer-events: none;
}

.topbar.is-scrolled {
  box-shadow: 0 8px 24px rgba(26, 42, 74, 0.08);
}

.topbar-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  padding: 0.45rem 0 0.5rem;
}

/* Brand: near full-width paper-boy banner + title row */
.brand {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  text-decoration: none;
  min-width: 0;
  width: 100%;
}

.brand:hover .logo {
  color: var(--navy-deep);
}

.brand-logo-rotator {
  position: relative;
  width: 100%;
  height: var(--banner-h);
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--cream-deep);
  box-shadow: 0 4px 16px rgba(26, 42, 74, 0.12);
}

.brand-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.7s ease, transform 0.9s ease;
}

.brand-logo.is-active {
  opacity: 1;
  transform: scale(1);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.logo {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.28rem;
  color: var(--navy);
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.1;
}

.logo span {
  color: var(--gold);
}

@media (prefers-reduced-motion: reduce) {
  .topbar,
  .brand-logo {
    transition: none;
  }
}

/* —— Feed layout —— */
.feed {
  padding: 0.45rem 0 1.75rem;
}

/* Masthead: solid brown rules, text only — no link */
.masthead {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-family: var(--serif);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--navy-mid);
  margin: 0.15rem 0 0.65rem;
  text-align: center;
  pointer-events: none;
  user-select: text;
}

.masthead::before,
.masthead::after {
  content: "";
  display: block;
  width: 1.75rem;
  height: 2px;
  background: var(--brown-rule);
  flex-shrink: 0;
}

/* —— Compact Reddit-style cards (single column) —— */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  position: relative;
}

.card--media {
  padding: 0;
  overflow: hidden;
  gap: 0;
  outline: none;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.card--media:hover,
.card--media:focus-within,
.card--media.is-previewing {
  box-shadow: 0 8px 22px rgba(26, 42, 74, 0.14);
  z-index: 2;
}

.card--media:focus-visible {
  outline: 2px solid var(--navy-mid);
  outline-offset: 2px;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.65rem 0.55rem;
  min-width: 0;
}

.card-media {
  position: relative;
  aspect-ratio: 2.15 / 1;
  overflow: hidden;
  background: var(--cream-deep);
  border-bottom: 1px solid var(--rule);
  isolation: isolate;
}

.card-thumb,
.card-preview,
.card-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-thumb {
  transition: opacity 0.35s ease, transform 0.45s ease;
  z-index: 1;
}

.card-preview {
  opacity: 0;
  transform: scale(1.08);
  transition: opacity 0.35s ease, transform 0.45s ease;
  z-index: 2;
  pointer-events: none;
}

.card-video {
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.3s ease, transform 0.4s ease;
  z-index: 2;
  pointer-events: none;
  background: #000;
}

.card--media:hover .card-thumb,
.card--media:focus-within .card-thumb,
.card--media.is-previewing .card-thumb {
  opacity: 0;
  transform: scale(1.06);
}

.card--media:hover .card-preview,
.card--media:focus-within .card-preview,
.card--media.is-previewing .card-preview {
  opacity: 1;
  transform: scale(1);
}

.card--media:hover .card-video,
.card--media:focus-within .card-video,
.card--media.is-previewing .card-video {
  opacity: 1;
  transform: scale(1);
}

.media-badge {
  position: absolute;
  left: 0.45rem;
  bottom: 0.45rem;
  z-index: 4;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream);
  background: rgba(15, 26, 48, 0.78);
  border-radius: 3px;
  padding: 0.22rem 0.4rem;
  pointer-events: none;
}

.media-hint {
  position: absolute;
  right: 0.45rem;
  top: 0.45rem;
  z-index: 4;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cream);
  background: rgba(15, 26, 48, 0.55);
  border-radius: 999px;
  padding: 0.18rem 0.45rem;
  opacity: 0.75;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.card--media:hover .media-hint,
.card--media:focus-within .media-hint,
.card--media.is-previewing .media-hint {
  opacity: 0;
}

@media (hover: none) {
  .media-hint {
    opacity: 1;
  }
  .media-hint::after {
    content: " · tap";
  }
}

.card-tag {
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--navy);
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.12rem 0.35rem;
  line-height: 1.2;
}

.card h3 {
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.25;
  margin: 0;
  color: var(--navy-deep);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.card-meta {
  font-size: 0.68rem;
  color: var(--muted);
  border-top: none;
  padding-top: 0.1rem;
  margin-top: 0;
  line-height: 1.2;
}

/* Wider: left thumb + text (Reddit-ish denser row) */
@media (min-width: 520px) {
  .card--media {
    flex-direction: row;
    align-items: stretch;
  }

  .card-media {
    width: 9.5rem;
    flex-shrink: 0;
    aspect-ratio: auto;
    align-self: stretch;
    min-height: 5.75rem;
    border-bottom: none;
    border-right: 1px solid var(--rule);
  }

  .card-body {
    flex: 1;
    padding: 0.45rem 0.7rem 0.5rem;
    justify-content: center;
  }

  .card h3 {
    font-size: 1.02rem;
  }

  .card p {
    font-size: 0.84rem;
  }
}

/* —— Footer (discreet privacy) —— */
footer {
  padding: 1rem 0 1.5rem;
  border-top: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  justify-content: space-between;
  align-items: center;
}

.footer-brand {
  font-family: var(--serif);
  color: var(--navy);
  font-size: 0.88rem;
  margin: 0;
}

.footer-meta {
  margin: 0;
  font-size: 0.75rem;
}

.footer-meta a {
  color: var(--muted);
  text-decoration: none;
}

.footer-meta a:hover {
  color: var(--navy-mid);
  text-decoration: underline;
}

/* —— Safe area / phone polish —— */
@supports (padding: max(0px)) {
  .topbar-inner,
  .wrap {
    padding-left: max(0.5rem, env(safe-area-inset-left));
    padding-right: max(0.5rem, env(safe-area-inset-right));
  }
}

@media (min-width: 641px) {
  :root {
    --banner-h: clamp(7.5rem, 18vw, 11rem);
  }

  body {
    font-size: 1.02rem;
  }

  .logo {
    font-size: 1.35rem;
  }

  .card--media .card-media {
    width: 11rem;
    min-height: 6.25rem;
  }

  .card h3 {
    font-size: 1.08rem;
  }
}

/* —— Brand rotator as clickable button —— */
button.brand-logo-rotator {
  margin: 0;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--cream-deep);
  cursor: zoom-in;
  font: inherit;
  box-shadow: 0 4px 16px rgba(26, 42, 74, 0.12);
}

button.brand-logo-rotator:focus-visible {
  outline: 2px solid var(--navy-mid);
  outline-offset: 2px;
}

a.logo {
  text-decoration: none;
}

/* —— Gallery —— */
.gallery-lead {
  margin: -0.2rem 0 0.85rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.4;
}

.gallery-lead code {
  font-size: 0.88em;
  background: var(--cream-deep);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.gallery-tile {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--card-shadow);
  cursor: zoom-in;
  font: inherit;
  color: inherit;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.gallery-tile img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--cream-deep);
}

.gallery-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
  padding: 0.4rem 0.5rem 0.5rem;
  border-top: 1px solid var(--rule);
  background: var(--cream);
}

.gallery-tile:focus-visible {
  outline: 2px solid var(--navy-mid);
  outline-offset: 2px;
}

@media (min-width: 641px) {
  .gallery-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
}

/* —— Lightbox —— */
body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.25rem;
  background: rgba(15, 26, 48, 0.88);
  backdrop-filter: blur(6px);
}

.lightbox[hidden] {
  display: none !important;
}

.lightbox-img {
  max-width: min(100%, 1100px);
  max-height: min(78vh, 900px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(247, 241, 228, 0.25);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  background: #0f1a30;
}

.lightbox-cap {
  margin: 0;
  color: var(--cream);
  font-size: 0.92rem;
  text-align: center;
  max-width: 36rem;
}

.lightbox-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid rgba(247, 241, 228, 0.35);
  border-radius: 999px;
  background: rgba(15, 26, 48, 0.7);
  color: var(--cream);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: rgba(176, 141, 62, 0.85);
  outline: none;
}
