@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Space+Mono:wght@400;700&family=IM+Fell+English&display=swap');

:root {
  --ink: #1a1a18;
  --paper: #f5f0e8;
  --cream: #ede8da;
  --accent: #c94a2a;
  --accent2: #2a5fc9;
  --accent3: #3a8c4a;
  --stamp: #8b2fc9;
  --rule: #1a1a18;
  --card-border: 2px solid var(--ink);
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Space Mono', monospace;
  min-height: 100vh;
}

/* ── MASTHEAD ── */
header {
  padding: 1.5rem 2rem 0;
  border-bottom: 3px solid var(--ink);
}

.masthead {
  text-align: center;
  padding-bottom: 1rem;
}

.masthead-rule {
  height: 2px;
  background: var(--ink);
  margin-bottom: 0.5rem;
}
.masthead-rule.thick {
  height: 5px;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.profile-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

.profile-btn {
  font-family: 'Playfair Display', serif;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  line-height: 1;
  text-transform: uppercase;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  opacity: 0.2;
  transition: opacity 0.15s;
  padding: 0;
}
.profile-btn:hover { opacity: 0.5; }
.profile-btn.active { opacity: 1; cursor: default; }

.profile-divider {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 400;
  opacity: 0.25;
  line-height: 1;
}

.masthead-sub {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
  text-transform: uppercase;
}

.dot { color: var(--accent); font-size: 0.5rem; }

/* ── CONTROLS ── */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
}

.filter-label {
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  opacity: 0.5;
  margin-right: 0.5rem;
  font-weight: 700;
}

.filter-section {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-chip {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border: 1.5px solid var(--ink);
  background: transparent;
  cursor: pointer;
  transition: all 0.1s;
  color: var(--ink);
}
.tag-chip:hover { background: var(--ink); color: var(--paper); }
.tag-chip.active { background: var(--accent); border-color: var(--accent); color: white; }
.tag-chip.pinned { border-color: var(--accent2); color: var(--accent2); }
.tag-chip.pinned:hover { background: var(--accent2); color: white; }
.tag-chip.pinned.active { background: var(--accent2); border-color: var(--accent2); color: white; }
.tag-chip.pinned .unpin { margin-left: 0.3rem; opacity: 0.5; font-style: normal; }
.tag-chip.pinned:hover .unpin { opacity: 1; }

.pin-form { display: flex; }
.pin-form input {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  width: 7rem;
  padding: 0.25rem 0.5rem;
  border: 1.5px dashed var(--ink);
  background: transparent;
  color: var(--ink);
  outline: none;
}
.pin-form input::placeholder { opacity: 0.35; }
.pin-form input:focus { border-style: solid; border-color: var(--accent2); }

.sort-buttons, .view-buttons {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--ink);
}

.sort-btn, .view-btn {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.6rem;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
  transition: all 0.1s;
  border-right: 1.5px solid var(--ink);
}
.sort-btn:last-child, .view-btn:last-child { border-right: none; }
.sort-btn.active, .view-btn.active { background: var(--ink); color: var(--paper); }
.sort-btn:hover:not(.active), .view-btn:hover:not(.active) { background: var(--cream); }

.clear-btn {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.75rem;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.clear-btn:hover { background: var(--accent); color: white; }
.hidden { display: none !important; }

/* ── MAIN ── */
main { padding: 1.5rem 2rem 4rem; }

.loading {
  text-align: center;
  padding: 4rem;
  font-size: 1rem;
  letter-spacing: 0.3em;
}
.dots { animation: blink 1.2s steps(3, end) infinite; }
@keyframes blink {
  0%, 100% { opacity: 0; }
  33% { opacity: 1; }
}

.error {
  text-align: center;
  padding: 3rem;
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

/* ── ZINE VIEW ── */
.feed.zine-view {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
  align-items: start;
}

.card {
  border: var(--card-border);
  background: var(--paper);
  overflow: hidden;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0 var(--ink);
}

/* Zine layout: varied column spans */
.zine-view .card:nth-child(7n+1) { grid-column: span 5; }
.zine-view .card:nth-child(7n+2) { grid-column: span 7; }
.zine-view .card:nth-child(7n+3) { grid-column: span 4; }
.zine-view .card:nth-child(7n+4) { grid-column: span 4; }
.zine-view .card:nth-child(7n+5) { grid-column: span 4; }
.zine-view .card:nth-child(7n+6) { grid-column: span 8; }
.zine-view .card:nth-child(7n+7) { grid-column: span 4; }

/* Slight rotations on some cards for that zine feel */
.zine-view .card:nth-child(5n+2) { transform: rotate(-0.4deg); }
.zine-view .card:nth-child(5n+2):hover { transform: rotate(-0.4deg) translateY(-2px); }
.zine-view .card:nth-child(5n+4) { transform: rotate(0.3deg); }
.zine-view .card:nth-child(5n+4):hover { transform: rotate(0.3deg) translateY(-2px); }

/* ── GRID VIEW ── */
.feed.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.grid-view .card { grid-column: span 1 !important; transform: none !important; }

/* ── LIST VIEW ── */
.feed.list-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 720px;
}
.list-view .card {
  grid-column: span 1 !important;
  transform: none !important;
  display: flex;
  flex-direction: row;
}
.list-view .card .card-img-wrap {
  width: 160px;
  flex-shrink: 0;
}
.list-view .card .card-img-wrap img {
  height: 100%;
  object-fit: cover;
}
.list-view .card .card-body { flex: 1; }

/* ── CARD INTERNALS ── */
.card-img-wrap {
  width: 100%;
  overflow: hidden;
  background: var(--cream);
  position: relative;
}

.card-img-wrap img {
  width: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 1;
  transition: transform 0.3s;
}
.card:hover .card-img-wrap img { transform: scale(1.02); }

.card-no-img {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: var(--cream);
  border-bottom: var(--card-border);
}

/* Tall cards show more of the image */
.zine-view .card:nth-child(7n+2) .card-img-wrap img,
.zine-view .card:nth-child(7n+6) .card-img-wrap img {
  aspect-ratio: 16/9;
}

.card-body {
  padding: 0.75rem;
  border-top: var(--card-border);
}

.card-date {
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  opacity: 0.5;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.card-caption {
  font-family: 'IM Fell English', serif;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 0.6rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.card-tag {
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  border: none;
  font-family: 'Space Mono', monospace;
}
.card-tag:hover { background: var(--accent); }

.card-meta {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.6rem;
  opacity: 0.55;
  letter-spacing: 0.08em;
}

.card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

/* Stamp accent on some cards */
.zine-view .card:nth-child(6n+1)::before {
  content: '✦';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 1.2rem;
  color: var(--accent);
  z-index: 2;
  pointer-events: none;
}

/* Multi-image indicator */
.multi-badge {
  position: absolute;
  bottom: 0.4rem;
  right: 0.4rem;
  background: rgba(0,0,0,0.65);
  color: white;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  padding: 0.15rem 0.4rem;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
}

/* ── LOAD MORE ── */
.load-more-wrap {
  text-align: center;
  margin-top: 2.5rem;
}

#load-more {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  padding: 0.75rem 2.5rem;
  border: 2px solid var(--ink);
  background: transparent;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.1s;
}
#load-more:hover { background: var(--ink); color: var(--paper); }

/* ── MASONRY VIEW ── */
.feed.masonry-view {
  display: block;
  columns: 3;
  column-gap: 1rem;
}
.masonry-view .card {
  break-inside: avoid;
  display: block;
  margin-bottom: 1rem;
  grid-column: unset !important;
  transform: none !important;
}
.masonry-view .card .card-img-wrap img {
  aspect-ratio: auto;
  height: auto;
}

/* ── POLAROID VIEW ── */
.feed.polaroid-view {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem 2rem;
  justify-content: center;
  padding: 2rem 1rem;
}
.polaroid-view .card {
  width: 20%;
  flex-shrink: 0;
  background: white;
  padding: 0.6rem 0.6rem 3.5rem;
  border: 1px solid #ccc;
  box-shadow: 2px 4px 16px rgba(0,0,0,0.16);
  grid-column: span 1 !important;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s, z-index 0s;
  z-index: 1;
}
.polaroid-view .card:nth-child(5n+1) { transform: rotate(-2.2deg); }
.polaroid-view .card:nth-child(5n+2) { transform: rotate(1.4deg); }
.polaroid-view .card:nth-child(5n+3) { transform: rotate(-0.7deg); }
.polaroid-view .card:nth-child(5n+4) { transform: rotate(2.6deg); }
.polaroid-view .card:nth-child(5n+5) { transform: rotate(-1.5deg); }
.polaroid-view .card:hover { transform: rotate(0deg) scale(1.06) translateY(-6px) !important; box-shadow: 4px 10px 32px rgba(0,0,0,0.28); z-index: 10; }
.polaroid-view .card .card-img-wrap img { aspect-ratio: 1; }
.polaroid-view .card .card-body { border-top: none; padding: 0.5rem 0.25rem 0; }
.polaroid-view .card .card-date { font-family: 'IM Fell English', serif; letter-spacing: 0.04em; text-align: center; font-style: italic; }
.polaroid-view .card .card-caption { font-size: 0.85rem; text-align: center; -webkit-line-clamp: 2; margin-bottom: 0.25rem; }
.polaroid-view .card .card-tags { display: none; }
.polaroid-view .card .card-meta { justify-content: center; font-size: 0.55rem; }

/* ── FILM VIEW (vertical strip) ── */
.feed.film-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #111;
  padding: 1.5rem 5rem;
  margin: -1.5rem -2rem -4rem;
  position: relative;
  min-height: 100vh;
}
.feed.film-view::before,
.feed.film-view::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4rem;
  background-color: #111;
  background-image: radial-gradient(circle at 50% 50%, #2a2a2a 42%, #111 42%);
  background-size: 4rem 3rem;
  background-repeat: repeat-y;
}
.feed.film-view::before { left: 0; }
.feed.film-view::after { right: 0; }
.film-view .card {
  width: 100%;
  max-width: 520px;
  grid-column: span 1 !important;
  transform: none !important;
  border-color: #2a2a2a;
  background: #1a1a1a;
  color: #ccc;
}
.film-view .card .card-body { border-top-color: #2a2a2a; }
.film-view .card .card-date { color: #777; }
.film-view .card .card-caption { color: #bbb; }
.film-view .card .card-meta a { color: #666; }
.film-view .card .card-tag { background: #2a2a2a; color: #aaa; }
.film-view .card .card-tag:hover { background: var(--accent); color: white; }
.film-view .card .card-img-wrap img { aspect-ratio: 3/2; filter: contrast(1.08) saturate(0.85); }
.film-view .card:hover { box-shadow: 0 0 0 1px #444; transform: none !important; }

/* ── NEWSPAPER VIEW ── */
.feed.newspaper-view {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0;
  border: 2px solid var(--ink);
}
.newspaper-view .card {
  border: none;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  transform: none !important;
  border-radius: 0;
}
.newspaper-view .card:nth-child(7n+1) {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: row;
}
.newspaper-view .card:nth-child(7n+1) .card-img-wrap { width: 55%; flex-shrink: 0; }
.newspaper-view .card:nth-child(7n+1) .card-img-wrap img { aspect-ratio: 16/9; height: 100%; object-fit: cover; }
.newspaper-view .card:nth-child(7n+1) .card-body { flex: 1; border-top: none; border-left: 1px solid var(--ink); padding: 1.25rem; }
.newspaper-view .card:nth-child(7n+1) .card-caption { -webkit-line-clamp: 8; font-size: 1.05rem; }
.newspaper-view .card:nth-child(7n+2),
.newspaper-view .card:nth-child(7n+3),
.newspaper-view .card:nth-child(7n+4),
.newspaper-view .card:nth-child(7n+5),
.newspaper-view .card:nth-child(7n+6),
.newspaper-view .card:nth-child(7n+7) { grid-column: span 4; }

/* ── TIMELINE VIEW ── */
.feed.timeline-view { display: block; }
.timeline-section { margin-bottom: 3rem; }
.timeline-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.4rem 0;
  margin-bottom: 1rem;
  border-top: 1px solid var(--ink);
  border-bottom: 3px double var(--ink);
}
.timeline-month {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.timeline-count {
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  opacity: 0.45;
}
.timeline-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* ── TAG CLOUD VIEW ── */
.feed.tagcloud-view { display: block; }
.tagcloud-wrap { width: 100%; position: relative; }
.tagcloud-canvas { display: block; width: 100%; cursor: default; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .feed.masonry-view { columns: 2; }
  .feed.zine-view { grid-template-columns: repeat(6, 1fr); }
  .zine-view .card:nth-child(7n+1) { grid-column: span 3; }
  .zine-view .card:nth-child(7n+2) { grid-column: span 6; }
  .zine-view .card:nth-child(7n+3) { grid-column: span 3; }
  .zine-view .card:nth-child(7n+4) { grid-column: span 3; }
  .zine-view .card:nth-child(7n+5) { grid-column: span 3; }
  .zine-view .card:nth-child(7n+6) { grid-column: span 6; }
  .zine-view .card:nth-child(7n+7) { grid-column: span 3; }
}

@media (max-width: 600px) {
  header, main { padding-left: 1rem; padding-right: 1rem; }
  .feed.zine-view { grid-template-columns: 1fr 1fr; }
  .zine-view .card { grid-column: span 1 !important; transform: none !important; }
  .feed.masonry-view { columns: 1; }
  .feed.film-view { padding: 1rem 3rem; margin-left: -1rem; margin-right: -1rem; }
  .feed.film-view::before, .feed.film-view::after { width: 2.5rem; }
  .polaroid-view .card { width: 160px; }
  .newspaper-view .card:nth-child(7n+1) { flex-direction: column; }
  .newspaper-view .card:nth-child(7n+1) .card-img-wrap { width: 100%; }
  .newspaper-view .card:nth-child(7n+2),
  .newspaper-view .card:nth-child(7n+3),
  .newspaper-view .card:nth-child(7n+4),
  .newspaper-view .card:nth-child(7n+5),
  .newspaper-view .card:nth-child(7n+6),
  .newspaper-view .card:nth-child(7n+7) { grid-column: span 6; }
}