/* Switchback — alpine field journal.
   Direction: warm paper + deep pine ink + golden-hour amber, topographic
   contour motifs, Fraunces (display serif) + Karla (body). Deliberately NOT
   a dark-mono or gradient-on-white site. */

:root {
  --paper: #f4efe3;
  --card: #fffdf6;
  --ink: #263528;
  --ink-soft: #63705f;
  --line: #ddd3ba;
  --line-soft: #e9e1cc;
  --amber: #d07f27;
  --amber-deep: #a95f12;
  --pine: #2e4a38;
  --pine-deep: #22392b;
  --danger: #a43e2c;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Karla", "Segoe UI", sans-serif;

  /* 4px-based spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  --radius: 16px;
  --feed-w: 560px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  /* faint topo contours, drawn in code */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='560' height='560' viewBox='0 0 560 560'%3E%3Cg fill='none' stroke='%23ded2b4' stroke-width='1' opacity='0.55'%3E%3Cpath d='M60 180c40-70 150-95 220-60s95 120 40 175S140 340 90 300 20 250 60 180z'/%3E%3Cpath d='M95 195c30-52 115-70 168-44s72 90 30 131-135 33-172 3-56-38-26-90z'/%3E%3Cpath d='M135 213c20-34 76-46 111-29s47 59 20 86-89 22-113 2-38-25-18-59z'/%3E%3Cpath d='M172 231c11-19 42-25 61-16s26 32 11 47-49 12-62 1-21-13-10-32z'/%3E%3Cpath d='M420 420c30-45 100-60 145-35s60 80 25 115-145 30-175 5-25-40 5-85z' /%3E%3Cpath d='M445 435c20-30 68-40 98-23s40 53 17 76-98 20-118 3-17-26 3-56z'/%3E%3Cpath d='M472 452c11-16 37-22 53-13s22 29 9 41-53 11-64 2-9-14 2-30z'/%3E%3C/g%3E%3C/svg%3E");
}

/* ── Header ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--feed-w); margin: 0 auto; padding: var(--s3) var(--s4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
}
.wordmark {
  display: inline-flex; align-items: center; gap: var(--s2);
  color: var(--pine-deep); text-decoration: none;
}
.mark { width: 30px; height: 30px; }
.wordmark-text {
  font-family: var(--font-display);
  font-style: italic; font-weight: 650; font-size: 24px; letter-spacing: -0.01em;
}
.wordmark:hover .wordmark-text { color: var(--amber-deep); }
.topnav { display: flex; align-items: center; gap: var(--s4); }
.topnav a {
  color: var(--ink-soft); text-decoration: none; font-weight: 700;
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.09em;
  padding: var(--s1) 0; border-bottom: 2px solid transparent;
}
.topnav a:hover, .topnav a.active { color: var(--pine-deep); border-bottom-color: var(--amber); }
.me-chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 5px 14px 5px 6px;
  font: 700 14px var(--font-body); cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.me-chip:hover { border-color: var(--amber); box-shadow: 0 2px 10px rgba(38, 53, 40, 0.10); }

/* ── Layout / views ─────────────────────────────────────── */
#app { max-width: var(--feed-w); margin: 0 auto; padding: var(--s6) var(--s4) var(--s8); }
.view[hidden] { display: none; }

.feed-head { margin-bottom: var(--s5); }
.eyebrow {
  margin: 0 0 var(--s2);
  font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--amber-deep);
}
.feed-title {
  margin: 0;
  font-family: var(--font-display); font-weight: 600; font-size: 44px;
  line-height: 1.05; letter-spacing: -0.015em; color: var(--pine-deep);
}
.feed-sub { margin: var(--s2) 0 0; color: var(--ink-soft); max-width: 42ch; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(38, 53, 40, 0.05), 0 8px 24px -18px rgba(38, 53, 40, 0.35);
}

/* ── Composer ───────────────────────────────────────────── */
.composer { padding: var(--s4); margin-bottom: var(--s6); }
.dropzone {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--s1);
  padding: var(--s5) var(--s4);
  background: transparent; color: var(--ink-soft);
  border: 1.6px dashed var(--line); border-radius: 12px;
  font: 500 15px var(--font-body); cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--amber); color: var(--pine-deep); background: #fbf7ea; }
.dz-icon { width: 30px; height: 30px; margin-bottom: var(--s1); }
.dz-label strong { color: var(--amber-deep); }
.dz-hint { font-size: 12.5px; color: var(--ink-soft); opacity: 0.85; }
.preview-wrap {
  border-radius: 12px; overflow: hidden; margin-bottom: var(--s3);
  border: 1px solid var(--line-soft); max-height: 420px;
}
.preview-wrap img { display: block; width: 100%; height: auto; max-height: 420px; object-fit: cover; }
.field-label {
  display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: var(--s1);
}
textarea, input[type="text"] {
  width: 100%; padding: var(--s2) var(--s3);
  font: 400 16px/1.5 var(--font-body); color: var(--ink);
  background: #fbf8ee; border: 1px solid var(--line); border-radius: 10px;
  resize: vertical;
}
textarea:focus, input[type="text"]:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }
.composer-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s3); }
.composer-status { margin: var(--s2) 0 0; font-size: 14px; color: var(--amber-deep); min-height: 1em; }
.composer-status:empty { margin: 0; min-height: 0; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  font: 700 15px var(--font-body); border-radius: 999px; cursor: pointer;
  padding: 9px 20px; border: 1px solid transparent;
  transition: background 0.18s, color 0.18s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn-solid { background: var(--pine); color: var(--card); }
.btn-solid:hover { background: var(--pine-deep); }
.btn-solid[disabled] { opacity: 0.55; cursor: wait; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-soft); }
.linklike {
  background: none; border: none; padding: 0; cursor: pointer;
  color: inherit; font: inherit; text-decoration: underline;
}
.linklike:hover { color: var(--amber-deep); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }

/* ── Feed cards ─────────────────────────────────────────── */
.feed-list { display: flex; flex-direction: column; gap: var(--s5); }
.post { overflow: hidden; }
.post-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); }
.post-author { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: var(--ink); min-width: 0; }
.post-author:hover .post-name { color: var(--amber-deep); }
.post-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.post-when { font-size: 12.5px; color: var(--ink-soft); }
.post-del {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--ink-soft); font-size: 13px; font-weight: 700; padding: var(--s1) var(--s2);
  border-radius: 8px;
}
.post-del:hover { color: var(--danger); background: #f7ece5; }
.post-photo { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: var(--line-soft); border-block: 1px solid var(--line-soft); }
.post-body { padding: var(--s3) var(--s4) var(--s4); }
.post-actions { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s2); }
.like-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: none; cursor: pointer; padding: var(--s1) 0;
  color: var(--ink-soft); font: 700 15px var(--font-body);
}
.like-btn .heart { width: 24px; height: 24px; transition: transform 0.15s; }
.like-btn:hover { color: var(--amber-deep); }
.like-btn:hover .heart { transform: scale(1.12); }
.like-btn.liked { color: var(--amber-deep); }
.like-btn.liked .heart path { fill: var(--amber); stroke: var(--amber-deep); }
.like-btn.pop .heart { animation: heartpop 0.35s ease; }
@keyframes heartpop { 40% { transform: scale(1.45); } 100% { transform: scale(1); } }
.post-caption { margin: 0 0 var(--s2); }
.post-caption a { color: inherit; font-weight: 700; text-decoration: none; }
.post-caption a:hover { color: var(--amber-deep); }
.comments { border-top: 1px solid var(--line-soft); padding-top: var(--s3); margin-top: var(--s2); }
.comment { margin: 0 0 var(--s2); font-size: 15px; }
.comment b { font-weight: 700; }
.comments-more {
  font-size: 13.5px; color: var(--ink-soft); background: none; border: none;
  padding: 0; cursor: pointer; margin-bottom: var(--s2);
}
.comments-more:hover { color: var(--ink); text-decoration: underline; }
.comment-row { display: flex; gap: var(--s2); margin-top: var(--s2); }
.comment-row input { flex: 1; font-size: 15px; padding: 7px var(--s3); }
.comment-row .btn { padding: 7px 16px; font-size: 14px; }
.feed-status { text-align: center; color: var(--ink-soft); font-style: italic; }
.feed-status:empty { display: none; }

/* ── Avatars (procedural — drawn from the visitor id) ───── */
.avatar { display: inline-block; border-radius: 50%; flex: none; }
.avatar:empty { display: none; }
.me-chip:has(.avatar:empty) { padding-left: 14px; }
.avatar svg { display: block; width: 100%; height: 100%; }
.avatar-sm { width: 26px; height: 26px; }
.avatar-md { width: 44px; height: 44px; }
.avatar-post { width: 40px; height: 40px; }
.avatar-lg { width: 72px; height: 72px; }

/* ── Profile ────────────────────────────────────────────── */
.backlink { display: inline-block; margin-bottom: var(--s4); color: var(--ink-soft); text-decoration: none; font-weight: 700; font-size: 14px; }
.backlink:hover { color: var(--amber-deep); }
.profile-head { display: flex; align-items: center; gap: var(--s4); padding: var(--s5); margin-bottom: var(--s5); }
.profile-name { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 32px; line-height: 1.1; color: var(--pine-deep); }
.profile-meta { margin: var(--s1) 0 0; color: var(--ink-soft); font-size: 14.5px; }
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.grid-item {
  position: relative; padding: 0; border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; cursor: pointer; background: var(--line-soft); aspect-ratio: 1 / 1;
}
.grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s; }
.grid-item:hover img { transform: scale(1.04); }

/* ── Modals ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(34, 41, 32, 0.45); padding: var(--s4);
}
.modal-backdrop[hidden] { display: none; }
.modal { width: 100%; max-width: 430px; padding: var(--s5); position: relative; }
.modal h2 { margin: 0 0 var(--s2); font-family: var(--font-display); font-weight: 600; font-size: 26px; color: var(--pine-deep); }
.modal-sub { margin: 0 0 var(--s4); color: var(--ink-soft); font-size: 15px; }
.register-row { display: flex; align-items: center; gap: var(--s3); }
.register-row input { flex: 1; }
.field-error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: var(--s2) 0 0; }
.modal-post { max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 0; }
.modal-post .post { border: none; box-shadow: none; }
.modal-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  background: var(--card); border: 1px solid var(--line); border-radius: 50%;
  width: 34px; height: 34px; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink-soft);
}
.modal-close:hover { color: var(--ink); border-color: var(--ink-soft); }

/* ── Footer ─────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--line); margin-top: var(--s8);
  padding: var(--s6) var(--s4) var(--s7); text-align: center; color: var(--ink-soft);
}
.footer-topo { width: min(360px, 80%); height: 14px; color: var(--line); margin-bottom: var(--s4); }
.footer-line { margin: 0 0 var(--s2); }
.footer-line strong { font-family: var(--font-display); font-style: italic; font-weight: 650; color: var(--pine-deep); }
.footer-nav { display: flex; justify-content: center; gap: var(--s4); margin-bottom: var(--s2); font-size: 14px; }
.footer-nav a { color: var(--ink-soft); }
.footer-nav a:hover { color: var(--amber-deep); }
.footer-colophon { margin: 0; font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }

/* ── 404 page ───────────────────────────────────────────── */
.lost { max-width: var(--feed-w); margin: 0 auto; padding: var(--s9) var(--s4); text-align: center; }
.lost h1 { font-family: var(--font-display); font-weight: 600; font-size: 56px; margin: 0 0 var(--s3); color: var(--pine-deep); line-height: 1; }
.lost p { color: var(--ink-soft); margin: 0 0 var(--s5); }

/* ── Mobile recomposition ───────────────────────────────── */
@media (max-width: 620px) {
  #app { padding: var(--s5) var(--s3) var(--s7); }
  .feed-title { font-size: 34px; }
  .feed-list { gap: var(--s4); }
  /* full-bleed photo cards on phones */
  .post { border-radius: 12px; }
  .topnav a[data-nav="feed"] { display: none; } /* wordmark already goes home */
  .profile-grid { gap: var(--s1); }
  .profile-head { padding: var(--s4); }
  .profile-name { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
