/* The Cozy Town Times — styled after the Paper of Record */

:root {
  --ink: #121212;
  --ink-soft: #363636;
  --gray: #5a5a5a;
  --gray-light: #727272;
  --rule: #dfdfdf;
  --rule-dark: #121212;
  --paper: #ffffff;
  --serif: georgia, "times new roman", times, serif;
  --sans: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif;
  --blackletter: "UnifrakturMaguntia", "Old English Text MT", georgia, serif;
}

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

body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a.hl:hover { color: var(--gray); }
img, svg { max-width: 100%; display: block; }

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */

.site-header { border-bottom: 1px solid var(--rule-dark); }

.topbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--sans);
  font-size: 0.6875rem;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
}
.topbar-left { display: flex; gap: 14px; }
.topbar .today { font-weight: 700; }
.topbar a { color: var(--gray); }
.topbar a:hover { text-decoration: underline; }
.topbar-right { display: flex; gap: 16px; color: var(--gray); }
.tick-up { color: #0a7c3f; }
.tick-down { color: #a52a1d; }

.masthead {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.masthead-side {
  font-family: var(--sans);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--gray);
  text-transform: uppercase;
}
.masthead-side.right { text-align: right; }

.nameplate {
  font-family: var(--blackletter);
  font-weight: 400;
  font-size: clamp(2.4rem, 6.5vw, 4.25rem);
  line-height: 1;
  text-align: center;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.section-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  border-top: 1px solid var(--rule);
}
.section-nav ul {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  padding: 8px 0;
}
.section-nav a {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  display: inline-block;
}
.section-nav a:hover, .section-nav a.active { text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------------ */
/* Front page                                                          */
/* ------------------------------------------------------------------ */

.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }

.front {
  display: grid;
  grid-template-columns: minmax(0, 2.05fr) minmax(0, 1fr);
  gap: 0 24px;
}

.front-main {
  padding-right: 24px;
  border-right: 1px solid var(--rule);
}

.kicker {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 6px;
}
.kicker.inline { display: inline; margin: 0; color: var(--gray); }

.lead-story { padding-bottom: 20px; border-bottom: 1px solid var(--rule); }
.lead-headline {
  font-size: clamp(1.6rem, 3.2vw, 2.25rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.lead-art figcaption, .story-art figcaption {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 300;
  color: var(--gray-light);
  padding-top: 6px;
  line-height: 1.5;
}
.lead-art { margin-bottom: 12px; }
.lead-art svg { width: 100%; height: auto; }

.summary {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.fp-byline {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 300;
  color: var(--gray-light);
}

.top-stories {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding-top: 20px;
}
.top-story { padding-right: 24px; border-right: 1px solid var(--rule); }
.top-story:last-child { border-right: none; padding-right: 0; }
.top-story h3 { font-size: 1.0625rem; font-weight: 700; line-height: 1.25; margin-bottom: 8px; }
.top-story .summary { font-size: 0.8125rem; }
.thumb { margin-bottom: 10px; }
.thumb svg { width: 100%; height: auto; }

/* Opinion rail */

.front-opinion { padding-top: 2px; }
.rail-label {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 700;
  border-bottom: 1px solid var(--rule-dark);
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.opinion-item { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--rule); }
.opinion-author {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  margin-bottom: 4px;
}
.opinion-headline { font-size: 1.125rem; font-weight: 400; font-style: italic; line-height: 1.3; margin-bottom: 6px; }

.rail-box {
  background: #f7f7f5;
  padding: 16px;
  margin-bottom: 16px;
}
.rail-box-label { font-family: var(--sans); font-size: 0.75rem; font-weight: 700; margin-bottom: 8px; }
.rail-box-text { font-size: 0.875rem; line-height: 1.5; color: var(--ink-soft); margin-bottom: 6px; }
.puzzle-box { border-top: 3px solid var(--ink); background: #fdf9ee; }

/* Lower grid */

.front-lower {
  grid-column: 1 / -1;
  margin-top: 32px;
  padding-top: 8px;
}
.lower-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}
.lower-story { padding-right: 24px; border-right: 1px solid var(--rule); }
.lower-story:last-child, .lower-grid .lower-story:nth-child(4n) { border-right: none; padding-right: 0; }
.lower-story h3 { font-size: 0.9375rem; font-weight: 700; line-height: 1.3; margin-bottom: 6px; }
.lower-story .summary { font-size: 0.8125rem; margin-bottom: 6px; }

/* ------------------------------------------------------------------ */
/* Article page                                                        */
/* ------------------------------------------------------------------ */

.story { max-width: 720px; margin: 12px auto 0; }

.story-section {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.story-section a:hover { text-decoration: underline; }
.story-section .sep { color: var(--rule); margin: 0 4px; }

.story-headline {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
  font-style: italic;
}
.story-subhead {
  font-size: 1.1875rem;
  line-height: 1.4;
  font-weight: 400;
  color: var(--ink-soft);
  margin-bottom: 22px;
}

.story-art { margin-bottom: 20px; }
.story-art svg { width: 100%; height: auto; }
.story-art .credit { color: #b0b0b0; }

.story-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 28px;
}
.story-byline { font-family: var(--sans); font-size: 0.8125rem; }
.story-byline .author { font-weight: 700; }
.story-date { font-family: var(--sans); font-size: 0.75rem; color: var(--gray-light); margin-top: 3px; }
.share-tools { display: flex; gap: 8px; }
.share-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  cursor: default;
}
.share-btn:hover { background: #f7f7f5; }

.story-body { max-width: 600px; margin: 0 auto; }
.story-body p {
  font-size: 1.1875rem;
  line-height: 1.75;
  margin-bottom: 1.6em;
}
.story-body p.opener::first-letter {
  font-size: 3.2em;
  font-weight: 700;
  float: left;
  line-height: 0.82;
  padding: 4px 8px 0 0;
}

.story-tagline {
  max-width: 600px;
  margin: 0 auto;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--gray-light);
  font-style: italic;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}

.related { max-width: 1200px; margin: 48px auto 0; }

/* ------------------------------------------------------------------ */
/* Section page                                                        */
/* ------------------------------------------------------------------ */

.section-header { border-bottom: 1px solid var(--rule-dark); padding-bottom: 14px; margin-bottom: 8px; }
.section-header h1 { font-size: 2rem; font-weight: 700; }
.section-tagline { font-size: 0.9375rem; color: var(--gray); margin-top: 4px; font-style: italic; }

.section-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}
.section-item h2 { font-size: 1.375rem; font-weight: 700; line-height: 1.25; margin-bottom: 8px; }
.section-thumb { margin: 0; }

/* ------------------------------------------------------------------ */
/* 404 + footer                                                        */
/* ------------------------------------------------------------------ */

.notfound { max-width: 600px; margin: 60px auto; text-align: center; }
.notfound h1 { font-size: 2rem; font-style: italic; margin-bottom: 16px; }

.site-footer {
  border-top: 3px double var(--ink);
  margin-top: 40px;
  padding: 28px 16px 40px;
  text-align: center;
}
.footer-nameplate { font-family: var(--blackletter); font-size: 1.75rem; }
.footer-motto { font-size: 0.8125rem; font-style: italic; color: var(--gray); margin: 6px 0 14px; }
.footer-links {
  list-style: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-bottom: 16px;
}
.footer-links a { font-family: var(--sans); font-size: 0.6875rem; font-weight: 600; color: var(--gray); }
.footer-links a:hover { text-decoration: underline; }
.footer-fine { font-family: var(--sans); font-size: 0.625rem; color: #b0b0b0; max-width: 620px; margin: 0 auto; line-height: 1.6; }

/* ------------------------------------------------------------------ */
/* Uploaded photos                                                     */
/* ------------------------------------------------------------------ */

.story-photo {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* ------------------------------------------------------------------ */
/* The Newsroom (admin)                                                */
/* ------------------------------------------------------------------ */

.newsroom { max-width: 1100px; margin: 0 auto; }

.newsroom-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.newsroom-actions { display: flex; gap: 8px; }

.import-report {
  font-family: var(--sans);
  font-size: 0.8125rem;
  border: 1px solid var(--rule);
  padding: 14px 16px;
  margin-top: 16px;
}
.import-report p { margin: 4px 0; }
.import-ok { color: #0a7c3f; }
.import-err { color: #a52a1d; }
.import-warn { color: var(--gray); font-style: italic; }
.newsroom-form textarea[name="payload"] { font-family: ui-monospace, Menlo, monospace; font-size: 0.8125rem; }

/* Auth */

.logout-form { display: inline; }
.logout-form button {
  font-family: var(--sans);
  font-size: 0.6875rem;
  color: var(--gray);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.logout-form button:hover { text-decoration: underline; }

.login-card {
  max-width: 420px;
  margin: 48px auto;
  border: 1px solid var(--rule);
  border-top: 3px solid var(--ink);
  padding: 28px 28px 20px;
}
.login-title { font-size: 1.5rem; font-style: italic; margin-bottom: 8px; }
.login-sub { font-size: 0.9375rem; line-height: 1.5; color: var(--ink-soft); margin-bottom: 16px; }
.login-error {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: #a52a1d;
  border: 1px solid #a52a1d;
  padding: 8px 12px;
  margin-bottom: 14px;
}
.login-form input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  font-size: 1rem;
  border: 1px solid #c9c9c9;
}

.api-token-box {
  font-family: var(--sans);
  font-size: 0.75rem;
  margin-top: 20px;
  border: 1px solid var(--rule);
  padding: 12px 16px;
}
.api-token-box summary { cursor: pointer; font-weight: 700; }
.api-token-box p { margin: 10px 0 4px; color: var(--gray); }
.api-token-box pre {
  background: #f7f7f5;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 0.6875rem;
  line-height: 1.5;
}

.spec-box {
  font-family: var(--sans);
  font-size: 0.75rem;
  margin-top: 24px;
  border: 1px solid var(--rule);
  padding: 12px 16px;
}
.spec-box summary { cursor: pointer; font-weight: 700; }
.spec-box .hint { display: block; color: var(--gray-light); margin: 10px 0; }
.spec-box #spec-text {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.6875rem;
  line-height: 1.5;
  border: 1px solid var(--rule);
  background: #f7f7f5;
  color: var(--ink-soft);
  resize: vertical;
}

.btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f2f2f0; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #333; }
.btn-danger { border-color: #a52a1d; color: #a52a1d; }
.btn-danger:hover { background: #a52a1d; color: var(--paper); }

.newsroom-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-family: var(--sans);
}
.newsroom-table th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule-dark);
}
.newsroom-table td {
  padding: 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
.cell-art { width: 88px; }
.cell-art svg, .cell-art .story-photo { width: 72px; aspect-ratio: 16/9; height: auto; }
.cell-headline { font-family: var(--serif); font-size: 0.9375rem; font-weight: 700; line-height: 1.3; }
.cell-meta { font-size: 0.75rem; color: var(--gray); white-space: nowrap; }
.cell-actions { white-space: nowrap; }
.cell-actions form { display: inline-block; margin-left: 6px; }

.badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  margin-left: 8px;
  background: var(--ink);
  color: var(--paper);
  vertical-align: middle;
}
.badge-soft { background: #f2f2f0; color: var(--gray); border: 1px solid var(--rule); }

.newsroom-note {
  font-family: var(--sans);
  font-size: 0.6875rem;
  color: var(--gray-light);
  font-style: italic;
  margin-top: 12px;
}

/* Story form */

.newsroom-form { max-width: 760px; }

.story-form fieldset {
  border: 1px solid var(--rule);
  padding: 20px;
  margin-top: 20px;
}
.story-form legend {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 8px;
}
.story-form label {
  display: block;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.story-form .hint { font-weight: 300; color: var(--gray-light); }
.story-form .req { font-weight: 300; color: #a52a1d; }
.story-form input[type="text"], .story-form select, .story-form textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  font-family: var(--serif);
  font-size: 0.9375rem;
  border: 1px solid #c9c9c9;
  background: var(--paper);
  color: var(--ink);
}
.story-form textarea { line-height: 1.6; resize: vertical; }
.story-form input:focus, .story-form select:focus, .story-form textarea:focus {
  outline: 2px solid var(--ink);
  outline-offset: -1px;
}
.story-form input[type="file"] { margin-top: 6px; font-family: var(--sans); font-size: 0.75rem; }
.story-form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.story-form .check input { margin: 0; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

.palette-inputs { display: flex; gap: 8px; margin-top: 5px; }
.palette-inputs input[type="color"] {
  width: 52px; height: 34px;
  padding: 2px;
  border: 1px solid #c9c9c9;
  background: var(--paper);
  cursor: pointer;
}

.art-preview { max-width: 380px; margin-bottom: 16px; }
.art-preview svg, .art-preview .story-photo { width: 100%; height: auto; }
.art-preview .hint { font-family: var(--sans); font-size: 0.6875rem; margin-top: 6px; display: block; }

.palette-help { font-family: var(--sans); font-size: 0.75rem; margin-bottom: 14px; }
.palette-help summary { cursor: pointer; font-weight: 600; }
.palette-help ul { list-style: none; margin-top: 8px; }
.palette-help li { display: flex; align-items: center; gap: 4px; padding: 3px 0; }
.palette-help li code { color: var(--gray-light); }
.swatch { width: 16px; height: 16px; display: inline-block; border: 1px solid var(--rule); }

.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .front { grid-template-columns: 1fr; }
  .front-main { border-right: none; padding-right: 0; }
  .front-opinion { margin-top: 28px; border-top: 3px solid var(--ink); padding-top: 14px; }
  .lower-grid { grid-template-columns: repeat(2, 1fr); }
  .lower-grid .lower-story:nth-child(2n) { border-right: none; padding-right: 0; }
  .masthead { grid-template-columns: 1fr; gap: 4px; }
  .masthead-side { display: none; }
}

@media (max-width: 600px) {
  .top-stories { grid-template-columns: 1fr; }
  .top-story { border-right: none; padding-right: 0; border-bottom: 1px solid var(--rule); padding-bottom: 16px; }
  .top-story:last-child { border-bottom: none; }
  .lower-grid { grid-template-columns: 1fr; }
  .lower-story { border-right: none; padding-right: 0; border-bottom: 1px solid var(--rule); padding-bottom: 16px; }
  .section-item { grid-template-columns: 1fr; }
  .section-thumb { order: -1; }
  .nameplate { white-space: normal; }
}
