/* Fern Community styles.
   Tokens copied verbatim from DESIGN.md / landing/index.html — do not
   redefine values locally; new tokens go into DESIGN.md first (the
   Photography set below landed with this feature). */

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1b2a1f;
  --muted: #5c6b5e;
  --accent: #2e6f4f;
  --accent-deep: #234d39;
  --accent-soft: #e8f0e5;
  --warmth: #d97757;
  --hairline: #e7e2d8;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --shadow-soft: 0 1px 2px rgba(27, 42, 31, 0.04), 0 8px 24px rgba(27, 42, 31, 0.06);
  --shadow-card: 0 1px 2px rgba(27, 42, 31, 0.05), 0 14px 36px rgba(27, 42, 31, 0.08);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Photography tokens (DESIGN.md → Photography) */
  --radius-photo: 14px;
  --avatar-sm: 32px;
  --avatar-lg: 72px;
  --feed-max: 520px;
  --grid-gap: 10px;
}

/* ===== Reset (matches landing pages) =============================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Shell + topbar (matches landing pages) ======================= */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 32px 96px;
}
@media (max-width: 640px) {
  .shell { padding: 16px 20px 64px; }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 36px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark { display: inline-flex; }
.brand-sub {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
}
.topnav-user {
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  color: var(--ink);
}
.topnav-user:hover { color: var(--accent); }
.inline-form { display: inline-flex; margin: 0; }

.quiet-link {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: var(--hairline);
  text-underline-offset: 4px;
}
.quiet-link:hover { color: var(--warmth); }
.quiet-link.danger:hover { color: #b33a2a; }

/* ===== Buttons (matches landing pages) ============================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(46, 111, 79, 0.2), 0 8px 20px rgba(46, 111, 79, 0.18);
  transition: transform 250ms ease-out, background 250ms ease-out;
}
.btn-primary:hover {
  transform: translateY(-2px);
  background: var(--accent-deep);
}
.btn-compact {
  padding: 9px 18px;
  font-size: 14px;
  white-space: nowrap;
}

@media (max-width: 540px) {
  .topbar { flex-wrap: wrap; row-gap: 14px; }
  .topnav { gap: 14px; margin-left: auto; }
  .quiet-link { white-space: nowrap; }
}

.btn-secondary {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: var(--warmth);
  text-underline-offset: 4px;
}
.btn-secondary:hover { color: var(--warmth); }

/* ===== Feed ========================================================= */
.feed {
  max-width: var(--feed-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 16px 16px 18px;
}

.post-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
}
.post-author {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.post-author-names { display: flex; flex-direction: column; line-height: 1.25; }
.post-username { font-weight: 600; font-size: 14px; color: var(--ink); }
.post-handle { font-size: 12px; color: var(--muted); }
.post-author:hover .post-username { color: var(--accent); }
.post-time { font-size: 12px; color: var(--muted); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 500;
  flex-shrink: 0;
}
.avatar-sm { width: var(--avatar-sm); height: var(--avatar-sm); font-size: 15px; }
.avatar-xs { width: 24px; height: 24px; font-size: 12px; }
.avatar-lg { width: var(--avatar-lg); height: var(--avatar-lg); font-size: 32px; }

.post-photo {
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-photo);
  background: var(--accent-soft);
}
.post-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 2px 0;
}
.like-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--ink);
  transition: transform 150ms ease-out;
}
.like-btn:hover { transform: scale(1.08); }
.like-btn .heart { transition: fill 150ms ease-in-out, color 150ms ease-in-out; }
.like-btn.is-liked { color: var(--accent); }
.like-btn.is-liked .heart { fill: var(--accent); }
.like-count {
  font-size: 14px;
  font-weight: 500;
  min-width: 18px;
}
.comment-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.comment-link:hover { color: var(--accent); }

.post-caption {
  margin: 10px 2px 0;
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.caption-user {
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
}
.caption-user:hover { color: var(--accent); }

.view-comments {
  display: inline-block;
  margin: 8px 2px 0;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
}
.view-comments:hover { color: var(--accent); }

.feed-more { text-align: center; padding: 8px 0 16px; }

/* ===== Comments ===================================================== */
.comments {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 20px;
}
.comment-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.comment {
  display: flex;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}
.comment:last-child { border-bottom: none; padding-bottom: 0; }
.comment-body p { margin: 0; font-size: 14.5px; overflow-wrap: anywhere; }
.comment-time { font-size: 12px; color: var(--muted); }
.no-comments { color: var(--muted); font-size: 14.5px; margin: 0 0 16px; }

.comment-form {
  display: flex;
  gap: 10px;
}
.comment-form input[type="text"] {
  flex: 1;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
}
.comment-form input[type="text"]::placeholder { color: var(--muted); }

.delete-form { margin: 16px 0 0; text-align: right; }

/* ===== Profile ====================================================== */
.profile { max-width: 760px; margin: 0 auto; }
.profile-head {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 0 32px;
}
.profile-meta { flex: 1; }
.profile-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.profile-handle { margin: 0; color: var(--muted); font-size: 14px; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--grid-gap);
}
@media (max-width: 540px) {
  .profile-grid { grid-template-columns: repeat(2, 1fr); }
}
.tile {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 250ms ease-out;
}
.tile:hover img { transform: scale(1.03); }
.tile-meta {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(27, 42, 31, 0.55);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

/* ===== Auth / form cards ============================================ */
.auth-card {
  max-width: 440px;
  margin: 24px auto 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 36px 32px;
}
.new-post-card { max-width: var(--feed-max); }
.auth-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}
.auth-sub { color: var(--muted); font-size: 15px; margin: 0 0 24px; }
.auth-sub code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}
.auth-sub a { color: var(--accent); }
.auth-foot { color: var(--muted); font-size: 13.5px; margin: 20px 0 0; }
.auth-foot a { color: var(--accent); }

.auth-form { display: flex; gap: 10px; }
.auth-form .btn-primary { white-space: nowrap; flex-shrink: 0; }
.auth-form-stack { flex-direction: column; gap: 6px; }

.auth-form input,
.new-post-form textarea,
.auth-form-stack input {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  width: 100%;
}
.code-input {
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
}
.auth-form-stack .btn-primary { margin-top: 18px; }

.field-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 12px;
}
.field-optional { font-weight: 400; text-transform: none; letter-spacing: 0; }

.form-error {
  color: #b33a2a;
  background: rgba(179, 58, 42, 0.07);
  border: 1px solid rgba(179, 58, 42, 0.2);
  border-radius: var(--radius-md);
  font-size: 14px;
  padding: 10px 14px;
  margin: 0 0 18px;
}

/* ===== New post form ================================================ */
.new-post-form { display: flex; flex-direction: column; gap: 6px; }
.photo-drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  border: 1.5px dashed var(--hairline);
  border-radius: var(--radius-photo);
  background: var(--bg);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 200ms ease-in-out;
}
.photo-drop:hover { border-color: var(--accent); }
.photo-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.photo-drop img {
  display: block;
  width: 100%;
  max-height: 480px;
  object-fit: contain;
}
.photo-drop-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.photo-drop-hint svg { color: var(--accent); }
.photo-drop-hint small { font-size: 12.5px; }

.caption-count {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
.new-post-form .btn-primary { margin-top: 14px; align-self: flex-end; }

/* ===== Empty states ================================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 72px 16px;
  color: var(--accent);
}
.empty-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 6px 0 0;
}
.empty-sub { color: var(--muted); font-size: 15px; margin: 0 0 12px; }

/* ===== Footer (matches landing pages) =============================== */
.footer {
  margin-top: 96px;
  padding-top: 56px;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 16px;
}
.footer code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}
.footer a {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: var(--hairline);
  text-underline-offset: 4px;
}
.footer a:hover { color: var(--warmth); }
.footer-links { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.install-app { color: var(--accent); text-decoration-color: var(--accent-soft); }
.ios-install-hint { font-size: 13px; color: var(--muted); }
