/* ============================================================
   Community component (sign-in, thumbs-up, comments)
   Loaded by: blog/restaurants.html, blog/events-calendar.html,
              and the four Fresh This Month issue pages.

   IMPORTANT — this file must not depend on ANY inherited custom
   property. The four FTM issue pages never load styles.css and
   define their own :root where the same names hold different
   values (--gold is #C9A227 there, #c6a052 in styles.css). So the
   component declares its own --tcm-* set on .tcm and reads only
   those. Fonts fall back to a stack rather than var(--display),
   for the same reason.

   Every class is prefixed tcm-. The site already uses generic
   .row, .link, .body and .btn, which would otherwise collide.
   ============================================================ */

.tcm {
  --tcm-gold: #9c7c34;
  --tcm-ink: #1c1b16;
  --tcm-muted: #5c564c;
  --tcm-line: #e7e0cf;
  --tcm-bg: #fff;
  --tcm-label: "Oswald", "Inter", system-ui, -apple-system, sans-serif;
  --tcm-body: "Inter", system-ui, -apple-system, sans-serif;
  font-family: var(--tcm-body);
  color: var(--tcm-ink);
}

/* The FTM issue pages sit on a cream sheet, not white. */
.tcm[data-skin="sheet"] {
  --tcm-gold: #C9A227;
  --tcm-ink: #1C1713;
  --tcm-muted: #4a443c;
  --tcm-line: #ddd2ba;
  --tcm-bg: #EDE6D6;
}

/* ---------- sign-in bar ---------- */
.tcm-authbar {
  max-width: 900px;
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 40px;          /* reserve height so the grid doesn't jump
                                when the async /api/auth/me lands */
  font-size: 14px;
}

.tcm-authbar[hidden] { display: none; }

.tcm-who {
  font-family: var(--tcm-label);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 12px;
  color: var(--tcm-muted);
}

.tcm-who b {
  color: var(--tcm-ink);
  font-weight: 600;
}

.tcm-linkbtn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-family: var(--tcm-label);
  color: var(--tcm-gold);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tcm-linkbtn:hover { color: var(--tcm-ink); }

.tcm-note {
  font-size: 13px;
  color: var(--tcm-muted);
}

.tcm-error {
  font-size: 13px;
  color: #8c2f22;
}

/* The GIS button renders itself into this div at its own size. */
.tcm-gbtn { min-height: 40px; }

/* ---------- sign-in nudge ---------- */
/* Clicking thumbs-up while signed out scrolls here and flashes, rather
   than opening a modal over what the reader was looking at. */
@keyframes tcm-flash {
  0%, 100% { background: transparent; }
  30%      { background: rgba(156,124,52,.16); }
}
.tcm-flash { animation: tcm-flash 1.4s ease; border-radius: 4px; }

/* Readers who ask for less motion get a static tint instead of the pulse,
   and the sign-in scroll jumps rather than glides (set in comments.js). */
@media (prefers-reduced-motion: reduce) {
  .tcm-flash { animation: none; background: rgba(156, 124, 52, .16); }
}

/* ---------- per-item thread block ---------- */
.tcm-thread {
  border-top: 1px solid var(--tcm-line);
  margin-top: 14px;
  padding-top: 12px;
}

.tcm-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tcm-up,
.tcm-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--tcm-line);
  border-radius: 999px;
  /* min-height gives a 44px tap target on touch; the vertical padding
     keeps the pill visually balanced without changing the flex row. */
  min-height: 44px;
  padding: 5px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--tcm-muted);
  line-height: 1;
  /* No layout shift between states: only color changes on toggle, so
     the row never reflows under the reader's finger. */
  transition: background .15s, border-color .15s, color .15s;
}

.tcm-up:hover,
.tcm-like:hover { border-color: var(--tcm-gold); color: var(--tcm-ink); }

.tcm-up.is-on,
.tcm-like.is-on {
  background: var(--tcm-gold);
  border-color: var(--tcm-gold);
  color: #fff;
}

.tcm-up:disabled,
.tcm-like:disabled { opacity: .55; cursor: default; }

/* The inline SVG inherits button color, so it flips to white with the
   rest of the button when the state turns on. */
.tcm-ico { width: 14px; height: 14px; display: block; flex: none; }
.tcm-crow .tcm-ico { width: 12px; height: 12px; }

.tcm-upn, .tcm-liken { font-weight: 600; font-variant-numeric: tabular-nums; }

.tcm-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  background: none;
  border: 0;
  padding: 0 2px;
  cursor: pointer;
  font-family: var(--tcm-label);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tcm-gold);
}
.tcm-toggle:hover { color: var(--tcm-ink); }

/* ---------- collapsed preview (the most-liked comment) ---------- */
.tcm-preview {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  font-family: var(--tcm-body);
  margin-top: 10px;
  padding: 0;
  font-size: 13px;
  color: var(--tcm-muted);
  cursor: pointer;
  line-height: 1.45;
}
.tcm-preview:hover { color: var(--tcm-ink); }
.tcm-pname { font-weight: 600; color: var(--tcm-ink); margin-right: 6px; }
.tcm-pbody { font-style: italic; }

/* ---------- expanded panel ---------- */
.tcm-panel { margin-top: 12px; }
.tcm-panel[hidden] { display: none; }

/* Fixed height + overscroll containment. Without `contain`, scrolling to
   the bottom of this box chains into the page on a phone, which feels
   like the page jumped on its own. */
.tcm-list {
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.tcm-c {
  padding: 9px 0;
  border-bottom: 1px solid var(--tcm-line);
  font-size: 14px;
}
.tcm-c:last-child { border-bottom: 0; }
.tcm-c.is-reply { margin-left: 18px; border-left: 2px solid var(--tcm-line); padding-left: 12px; }
.tcm-c.is-pending { opacity: .75; }

.tcm-chead { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.tcm-cname { font-weight: 600; font-size: 13px; color: var(--tcm-ink); }
.tcm-ctime { font-size: 11px; color: var(--tcm-muted); }

/* Long unbroken strings — a pasted URL, a wall of one character — must
   wrap rather than widen the card and push the grid sideways. */
.tcm-cbody {
  margin: 0 0 6px;
  line-height: 1.5;
  color: var(--tcm-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tcm-pendingnote { margin: 0 0 6px; font-size: 12px; color: var(--tcm-gold); }
.tcm-crow { display: flex; align-items: center; gap: 12px; }
.tcm-crow .tcm-like { padding: 3px 9px; font-size: 12px; }
.tcm-danger { color: #8c2f22; }
.tcm-danger:hover { color: #6d241a; }

/* ---------- write form ---------- */
.tcm-form { margin-top: 12px; }
.tcm-form.is-reply { margin-top: 8px; margin-left: 18px; }

.tcm-ta {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--tcm-line);
  border-radius: 4px;
  padding: 9px 10px;
  font-family: var(--tcm-body);
  font-size: 14px;
  color: var(--tcm-ink);
  background: var(--tcm-bg);
  resize: vertical;
  min-height: 58px;
}
.tcm-ta:focus { outline: 2px solid var(--tcm-gold); outline-offset: 1px; }

/* Visible keyboard focus for every interactive control in the component.
   Nothing sets outline:none, so these simply add a clear gold ring that
   reads on both the white and cream backgrounds. */
.tcm-up:focus-visible,
.tcm-like:focus-visible,
.tcm-toggle:focus-visible,
.tcm-send:focus-visible,
.tcm-linkbtn:focus-visible,
.tcm-preview:focus-visible,
.tcm-morebtn:focus-visible {
  outline: 2px solid var(--tcm-gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.tcm-formfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
}

.tcm-count { font-size: 12px; color: var(--tcm-muted); font-variant-numeric: tabular-nums; }
.tcm-count.is-low { color: #8c2f22; }

.tcm-send {
  font-family: var(--tcm-label);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 18px;
  border: 0;
  border-radius: 2px;
  background: var(--tcm-gold);
  color: #fff;
  cursor: pointer;
}
.tcm-send:hover { background: var(--tcm-ink); }
.tcm-send:disabled { opacity: .6; cursor: default; }

/* ---------- "Show more comments" ---------- */
.tcm-morewrap:empty { display: none; }
.tcm-morebtn {
  display: block;
  margin: 10px auto 0;
  background: none;
  border: 0;
  padding: 6px 4px;
  cursor: pointer;
  font-family: var(--tcm-label);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tcm-gold);
}
.tcm-morebtn:hover { color: var(--tcm-ink); }
.tcm-morebtn:disabled { opacity: .6; cursor: default; }

.tcm-msg { margin: 7px 0 0; font-size: 13px; }
.tcm-msg:empty { display: none; }
.tcm-msg.is-pending { color: var(--tcm-gold); }
