/* ===================================================================
   feed.css — Exla's Blog tile feed
   Matches the original Paradigm Shift aesthetic:
   white background · black text · Manrope + Space Grotesk
   =================================================================== */

@font-face {
  font-family: manrope;
  src: url('webfonts/Manrope.TTF') format('truetype'),
       url('webfonts/Manrope.woff2') format('woff2');
}

@font-face {
  font-family: spaceGrotesk;
  src: url('webfonts/SpaceGrotesk.TTF') format('truetype'),
       url('webfonts/SpaceGrotesk.woff2') format('woff2');
}

/* ===================================================================
   RESET / BASE
   =================================================================== */

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

html {
  font-size: 13pt;
  overflow-x: hidden;
}

body {
  /* Sage green fills the margins left and right of the grid */
  background-color: #A4BAB7;
  /* SVG eyecatcher sits in both side margins, fixed while scrolling */
  background-image: url('index.svg'), url('index.svg');
  background-repeat: no-repeat, no-repeat;
  background-position: left bottom, right bottom;
  background-size: 24vw auto, 24vw auto;
  background-attachment: fixed, fixed;
  color: #000000;
  font-family: manrope, Helvetica, sans-serif;
  font-weight: 300;
  letter-spacing: 0.0375em;
  line-height: 2;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

a {
  color: #000000;
  text-decoration: none;
  border-bottom: dotted 1px;
  transition: border-bottom-color 0.25s ease-in-out;
}

a:hover { border-bottom-color: transparent; }

button { cursor: pointer; }

/* ===================================================================
   HEADER
   =================================================================== */

#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #A4BAB7;
  border-bottom: solid 2px #A52422;
  height: 4rem;
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
}

.site-logo {
  font-family: manrope, Helvetica, sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #000000;
  text-decoration: none;
  border: none;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
}

/* filter nav */
#tag-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

#tag-nav::-webkit-scrollbar { display: none; }

.tag-btn {
  background: none;
  border: solid 1px rgba(144, 144, 144, 0.3);
  color: rgba(0, 0, 0, 0.4);
  font-family: spaceGrotesk, Helvetica, sans-serif;
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 0;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tag-btn:hover {
  color: #000000;
  border-color: #000000;
}

.tag-btn.active {
  background: #A4BAB7;
  color: #000000;
  border-color: #A4BAB7;
}

/* header icons */
.header-icons {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-shrink: 0;
}

.header-icon {
  color: rgba(0, 0, 0, 0.4);
  text-decoration: none;
  border: none;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.2s;
}

.header-icon:hover { color: #000000; }

#dark-toggle {
  background: none;
  padding: 0;
  font-size: inherit;
}

.header-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
}

/* ===================================================================
   FEED GRID
   =================================================================== */

#feed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 3px;
}

/* Individual tile */
.tile {
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: #A4BAB7; /* sage green shows while images load */
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

/* Hover overlay */
.tile-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 0.75rem;
  transition: background 0.3s ease;
}

.tile-title {
  font-family: spaceGrotesk, Helvetica, sans-serif;
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0);
  line-height: 1.5;
  transition: color 0.3s ease;
}

.tile-count {
  font-family: manrope, Helvetica, sans-serif;
  font-size: 0.45rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0);
  margin-top: 0.1rem;
  transition: color 0.3s 0.05s ease;
}

.tile:hover img {
  transform: scale(1.04);
}

.tile:hover .tile-overlay {
  background: rgba(0, 0, 0, 0.5);
}

.tile:hover .tile-title,
.tile:hover .tile-count {
  color: rgba(255, 255, 255, 0.95);
}

/* Multi-image badge (top right) */
.tile-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  opacity: 0.9;
}

.tile-badge svg {
  width: 100%;
  height: 100%;
  fill: #ffffff;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
}

/* Tag badge (top left, only visible on hover) */
.tile-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  font-family: spaceGrotesk, Helvetica, sans-serif;
  font-size: 0.42rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0);
  padding: 2px 6px;
  border: solid 1px rgba(255, 255, 255, 0);
  transition: all 0.25s ease;
}

.tile:hover .tile-tag {
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Text-only tile */
.tile-text-only {
  background: #000000;
}

.tile-text-only .tile-text-bg {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1rem;
  gap: 0.4rem;
}

.tile-text-only .tile-text-bg .tile-tag-label {
  font-family: spaceGrotesk, Helvetica, sans-serif;
  font-size: 0.45rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
}

.tile-text-only .tile-text-bg p {
  font-family: manrope, Helvetica, sans-serif;
  font-size: 0.65rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
  letter-spacing: 0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-text-only .tile-text-bg small {
  font-size: 0.42rem;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: auto;
}

/* ===================================================================
   EMPTY STATE
   =================================================================== */

#empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: calc(100vh - 4rem);
  text-align: center;
  padding: 2rem;
}

#empty-state h3 {
  font-family: spaceGrotesk, Helvetica, sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.175em;
  text-transform: uppercase;
  color: #000000;
}

#empty-state p {
  font-size: 0.8rem;
  color: rgba(0, 0, 0, 0.45);
  letter-spacing: 0.0375em;
}

#empty-state a {
  color: #000000;
}

/* ===================================================================
   POST MODAL
   =================================================================== */

#modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#modal.open {
  opacity: 1;
  pointer-events: all;
}

#modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.92);
  background-image: url('index.svg'), url('index.svg');
  background-position: left bottom, right bottom;
  background-size: 22vw auto, 22vw auto;
  background-repeat: no-repeat, no-repeat;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

#modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 960px;
  max-height: calc(100vh - 4rem);
  background: transparent;
  border: none;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  transform: translateY(10px);
  transition: transform 0.25s ease;
}

#modal.open #modal-panel {
  transform: translateY(0);
}

/* Image column — single-image carousel */
#modal-image-wrap {
  flex: 0 0 60%;
  background: transparent;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* When info panel is visible (first image), right-align the image so its
   right border is flush with the info panel — no gap between them. */
#modal-panel:not(.image-only) #modal-image-wrap {
  justify-content: flex-end;
}

#modal-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
  transform-origin: center center;
  will-change: transform;
  /* flex item at z-index: auto = 0, always above the z-index: -1 peeks */
}

/* Peek images — positioned by JS to align with rendered image edges */
.img-peek {
  position: absolute;
  object-fit: cover;
  opacity: 0.55;
  z-index: 0;  /* above overlay (auto), below panel (z-index:1) */
  pointer-events: none;
}

#img-peek-prev {
  object-position: right center;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 60%);
  mask-image: linear-gradient(to right, transparent 0%, black 60%);
}

#img-peek-next {
  object-position: left center;
  -webkit-mask-image: linear-gradient(to left, transparent 0%, black 60%);
  mask-image: linear-gradient(to left, transparent 0%, black 60%);
}

/* Overlay prev/next buttons on the image */
.img-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border: none;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 1;
  transition: background 0.2s;
}
.img-nav-btn:hover:not(:disabled) { background: rgba(0, 0, 0, 0.65); }
.img-nav-btn:disabled { opacity: 0.15; cursor: default; }
#img-prev { left: 0.75rem; }
#img-next { right: 0.75rem; }

#img-counter {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-family: manrope, Helvetica, sans-serif;
  font-size: 0.55rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  pointer-events: none;
  white-space: nowrap;
}

/* Info sidebar */
#modal-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  min-width: 0;
}

/* Top bar: tag + date + close */
#modal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  background: #A4BAB7;
  border-bottom: solid 2px rgba(144, 144, 144, 0.15);
  flex-shrink: 0;
  gap: 0.75rem;
}

.modal-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-left: 0.75rem;
  position: relative;
}

.modal-meta::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #A52422;
}

#modal-tag {
  font-family: spaceGrotesk, Helvetica, sans-serif;
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #A52422;
}

#modal-date {
  font-family: manrope, Helvetica, sans-serif;
  font-size: 0.6rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: rgba(0, 0, 0, 0.4);
}

#modal-location {
  font-family: manrope, Helvetica, sans-serif;
  font-size: 0.6rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: rgba(0, 0, 0, 0.4);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  transition: color 0.2s, border-color 0.2s;
}
#modal-location:hover {
  color: #A52422;
  border-bottom-color: #A52422;
}

#modal-close {
  background: none;
  border: none;
  color: rgba(0, 0, 0, 0.35);
  font-size: 1rem;
  font-family: manrope, Helvetica, sans-serif;
  line-height: 1;
  flex-shrink: 0;
  padding: 0;
  transition: color 0.2s;
}

#modal-close:hover { color: #000000; }

/* Caption / text body */
#modal-body {
  flex: 1;
  padding: 1.25rem;
  background: #d1dcdb;
  overflow-y: auto;
  font-family: manrope, Helvetica, sans-serif;
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 0.0375em;
  line-height: 1.9;
  color: #000000;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(144,144,144,0.3) transparent;
}

#modal-body::-webkit-scrollbar { width: 4px; }
#modal-body::-webkit-scrollbar-thumb {
  background: rgba(144,144,144,0.25);
}

#modal-body.is-empty {
  color: rgba(0, 0, 0, 0.3);
  font-style: italic;
}

#modal-body a {
  color: #A52422;
  text-decoration: none;
  border-bottom: 1px solid #A52422;
}
#modal-body a:hover {
  border-bottom-color: transparent;
}


/* Keyboard hint */
#modal-hint {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: spaceGrotesk, Helvetica, sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  pointer-events: none;
}

/* Image-only mode: images 2+ fill the full panel */
#modal-panel.image-only #modal-image-wrap {
  flex: 1;
}
#modal-panel.image-only #modal-info {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: transparent;
  border: none;
  padding: 0;
  z-index: 3;
  flex: none;
  max-height: none;
  overflow: visible;
}
#modal-panel.image-only #modal-top {
  background: transparent;
  border: none;
  padding: 0;
}
#modal-panel.image-only .modal-meta {
  display: none;
}
#modal-panel.image-only #modal-body {
  display: none;
}
#modal-panel.image-only #modal-close {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
#modal-panel.image-only #modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
}

/* No-image modal: center the text panel */
#modal-panel.no-image #modal-image-wrap {
  display: none;
}

#modal-panel.no-image #modal-info {
  border-left: none;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */

@media screen and (max-width: 736px) {
  html { font-size: 12pt; }

  #feed-grid {
    gap: 2px;
    padding: 2px;
    max-width: 100%;
  }

  .header-inner { padding: 0 1rem; }

  #modal {
    padding: 0;
    align-items: flex-end;
  }

  #modal-panel {
    flex-direction: column;
    max-width: 100%;
    height: 95svh;
    max-height: 95svh;
    border-top: none;
  }

  #modal-image-wrap {
    flex: 1;
    height: auto;
    width: 100%;
    order: 2;
  }

  /* First image (info visible): center info+image together, touching */
  #modal-panel:not(.image-only) {
    justify-content: center;
  }

  #modal-panel:not(.image-only) #modal-image-wrap {
    flex: 0 0 auto;        /* shrink-wrap to image height, don't fill remaining space */
    justify-content: center;
  }

  /* Cap image height so portrait images don't overflow the panel */
  #modal-panel:not(.image-only) #modal-img {
    max-height: 55svh;
  }

  #modal-info {
    order: 1;
    border-left: none;
    border-bottom: none;
    border-top: none;
    flex: 0 0 auto;
    min-height: 0;
    max-height: 42%;
    overflow: hidden;
  }

  #modal-panel.no-image #modal-info {
    max-width: 100%;
    max-height: 100%;
    flex: 1;
    order: 1;
  }

  #modal-panel.image-only #modal-image-wrap {
    flex: 1;
    height: auto;
  }

  .img-peek { display: none; }

  #modal-hint { display: none; }
}

@media screen and (max-width: 480px) {
  html { font-size: 11pt; }

  .header-icons { gap: 0.5rem; }

  .tag-btn {
    font-size: 0.46rem;
    padding: 0.25rem 0.55rem;
  }
}

/* ===================================================================
   DARK MODE
   =================================================================== */

body.dark {
  background-color: #1c2a27;
  color: #e0e0e0;
}

body.dark #site-header {
  background: #1c2a27;
}

body.dark .site-logo { color: #e0e0e0; }

body.dark a { color: #e0e0e0; }

body.dark .tag-btn {
  color: rgba(255, 255, 255, 0.4);
  border-color: rgba(255, 255, 255, 0.15);
}

body.dark .tag-btn:hover {
  color: #e0e0e0;
  border-color: #e0e0e0;
}

body.dark .tag-btn.active {
  background: #1c2a27;
  color: #e0e0e0;
  border-color: #1c2a27;
}

body.dark .header-icon { color: rgba(255, 255, 255, 0.4); }
body.dark .header-icon:hover { color: #e0e0e0; }

body.dark #dark-toggle { background: none; }

#icon-sun { display: none; }
body.dark #icon-moon { display: none; }
body.dark #icon-sun  { display: block; }

body.dark .tile { background: #1c2a27; }

body.dark .tile-text-only { background: #111; }

body.dark #empty-state h3 { color: #e0e0e0; }
body.dark #empty-state p  { color: rgba(255, 255, 255, 0.45); }
body.dark #empty-state a  { color: #e0e0e0; }

body.dark #modal-overlay {
  background-color: rgba(0, 0, 0, 0.88);
}

body.dark #modal-info { background: #1a1a1a; }

body.dark #modal-top {
  background: #1c2a27;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.dark #modal-date,
body.dark #modal-location { color: rgba(255, 255, 255, 0.4); }

body.dark #modal-close { color: rgba(255, 255, 255, 0.35); }
body.dark #modal-close:hover { color: #e0e0e0; }

body.dark #modal-body {
  background: #222;
  color: #e0e0e0;
}

body.dark #modal-body.is-empty { color: rgba(255, 255, 255, 0.3); }

body.dark #modal-hint { color: rgba(255, 255, 255, 0.2); }
