/* Senior Moments Club — Soft Heritage palette */
:root {
  --ivory: #faf6ee;
  --paper: #fffdf8;
  --slate: #334c62;
  --slate-soft: #4d6479;
  --coral: #c47764;
  --coral-dark: #a45c4a;   /* AA contrast on ivory for text/buttons */
  --text: #2b2f33;
  --muted: #5f6b75;
  --line: #e4dccd;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 112.5%; } /* 18px base for comfortable reading */

body {
  margin: 0;
  background: var(--ivory);
  color: var(--text);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  line-height: 1.6;
}

h1, h2, h3, .tagline, .site-nav, .button, .byline, .src, .more {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

h1, h2, h3 { color: var(--slate); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; padding-bottom: .35rem; border-bottom: 2px solid var(--coral); margin-bottom: 1rem; }
h3 { font-size: 1.05rem; }

a { color: var(--slate); text-decoration-color: var(--coral); text-underline-offset: 3px; }
a:hover { color: var(--coral-dark); }
a:focus-visible, .button:focus-visible {
  outline: 3px solid var(--coral-dark);
  outline-offset: 3px;
  border-radius: 3px;
}

.skip { position: absolute; left: -999px; top: 0; background: var(--slate); color: #fff; padding: .6rem 1rem; z-index: 10; }
.skip:focus { left: 0; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 1.25rem; }
.narrow { max-width: 760px; }

/* Header */
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner { padding-top: 1.1rem; padding-bottom: 1rem; text-align: center; }
.logo { display: block; width: min(480px, 100%); margin: 0 auto; }
.logo img { display: block; width: 100%; height: auto; }
.tagline { margin: .35rem 0 .8rem; color: var(--muted); font-size: .95rem; }

.site-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.4rem; align-items: center; font-size: .95rem; }
.site-nav a { text-decoration: none; font-weight: 600; padding: .35rem .2rem; }
.site-nav a:hover { text-decoration: underline; }
.site-nav .nav-cta { background: var(--coral-dark); color: #fff; padding: .45rem 1rem; border-radius: 999px; }
.site-nav .nav-cta:hover { background: var(--slate); color: #fff; text-decoration: none; }

/* Three-column layout: mobile shows stories first */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "centre" "left" "right";
  gap: 1.5rem;
  padding-top: 1.75rem;
  padding-bottom: 2.5rem;
}
.col-centre { grid-area: centre; min-width: 0; }
.col-left   { grid-area: left; min-width: 0; }
.col-right  { grid-area: right; min-width: 0; }

@media (min-width: 720px) {
  .layout { grid-template-columns: 1fr 1fr; grid-template-areas: "centre centre" "left right"; }
}
@media (min-width: 1040px) {
  .layout { grid-template-columns: minmax(230px, 1fr) minmax(0, 2fr) minmax(230px, 1fr); grid-template-areas: "left centre right"; gap: 2rem; }
}

/* Cards */
.welcome, .story, .col-left, .col-right {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
}
.welcome { margin-bottom: 1.75rem; }

.lead { font-size: 1.12rem; color: var(--slate-soft); }
.story { margin-bottom: 1.1rem; }
.story h3 { font-size: 1.2rem; }
.byline { color: var(--muted); font-size: .85rem; margin: 0 0 .6rem; }
.more { font-weight: 600; font-size: .9rem; }

.button {
  display: inline-block;
  background: var(--coral-dark);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  padding: .8rem 1.6rem;
  border-radius: 999px;
  font-size: 1.05rem;
}
.button:hover { background: var(--slate); color: #fff; }

/* Headlines */
.col-left h2, .col-right h2 { font-size: 1.15rem; }
.topic { margin-bottom: 1.1rem; }
.topic h3 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--coral-dark); margin-bottom: .3rem;
}
.topic ul { list-style: none; margin: 0; padding: 0; }
.topic li { margin: 0 0 .55rem; font-size: .93rem; line-height: 1.4; }
.topic a { text-decoration: none; font-weight: 600; }
.topic a:hover { text-decoration: underline; }
.src { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; }

ul.plain { padding-left: 1.2rem; }
ul.plain li { margin-bottom: .6rem; }
.muted { color: var(--muted); font-size: .9rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--paper); padding: 1.25rem 0; text-align: center; color: var(--muted); }
.site-footer p { margin: .2rem 0; }
.small { font-size: .85rem; }

@media (prefers-reduced-motion: no-preference) {
  a, .button { transition: color .15s, background-color .15s; }
}

/* ================= Milestone 2: forms, story pages, editor area =================
   Additions only: the approved homepage rules above are unchanged. */

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; }
.page { margin-bottom: 1.5rem; margin-top: 1.5rem; }
.page-title { margin-top: 1.5rem; }
.preline { white-space: pre-line; }
.small { font-size: .85rem; }

/* Forms */
.form .field { margin-bottom: 1.25rem; }
.form label { display: block; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-weight: 600; color: var(--slate); margin-bottom: .3rem; }
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form input[type="file"], .form textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: #fff;
  border: 1px solid #8d8574; border-radius: 8px; padding: .65rem .8rem;
}
.form textarea { line-height: 1.55; resize: vertical; min-height: 6rem; }
.form input:focus-visible, .form textarea:focus-visible { outline: 3px solid var(--coral-dark); outline-offset: 2px; }
.form [aria-invalid="true"] { border-color: #a1301f; border-width: 2px; }
.help { color: var(--muted); font-size: .88rem; margin: .3rem 0 0; }
.field-error { color: #8a2a1a; font-weight: 600; font-size: .92rem; margin: .35rem 0 0; }
.field-check { display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; align-items: start; }
.field-check input[type="checkbox"] { width: 1.35rem; height: 1.35rem; margin-top: .2rem; accent-color: var(--slate); }
.field-check label { font-weight: 400; color: var(--text); margin: 0; }
.field-check .field-error { grid-column: 2; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.alert { border-left: 5px solid; border-radius: 8px; padding: .8rem 1rem; margin: 1rem 0; }
.alert p { margin: .2rem 0; }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.alert-error { background: #fbeeea; border-color: #a1301f; color: #5a1f14; }
.alert-info { background: #eef3f7; border-color: var(--slate); color: var(--text); }
.alert-ok { background: #edf5ed; border-color: #3f7a3f; color: #1f3d1f; }
.alert-error a { color: inherit; }

.button-small { font-size: .85rem; padding: .45rem 1rem; }
.button-secondary { background: var(--slate); }
.button-secondary:hover { background: var(--coral-dark); }
.button-quiet { background: transparent; color: var(--slate); border: 1px solid var(--slate); }
.button-quiet:hover { background: var(--slate); color: #fff; }
.button-danger { background: #8a2a1a; }
.button-danger:hover { background: #5a1f14; }
button.button { border: 0; cursor: pointer; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
button.button-quiet { border: 1px solid var(--slate); }

/* Story cards link titles, invitation card, story page */
.story h3 a { text-decoration: none; }
.story h3 a:hover { text-decoration: underline; }
.story.invite { border-style: dashed; }
.story-page { padding: 1.5rem 1.6rem; }
.story-page h1 { font-size: 1.9rem; margin-bottom: .3rem; }
.story-page .byline { font-size: .92rem; margin-bottom: 1.2rem; }
.story-body { font-size: 1.1rem; line-height: 1.8; max-width: 66ch; }
.story-body p { margin: 0 0 1.1em; }
.story-figure { margin: 0 0 1.4rem; }
.story-figure img { display: block; max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.story-nav { margin: 0 0 2rem; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: .95rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; align-items: center; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; margin: 1.5rem 0 2.5rem; }

/* Editor area */
body.admin { background: #f4f1ea; }
.admin-bar { background: var(--slate); color: #fff; }
.admin-bar a { color: #fff; }
.admin-bar-inner { display: flex; flex-wrap: wrap; gap: .6rem 1.5rem; align-items: center; padding-top: .6rem; padding-bottom: .6rem; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: .95rem; }
.admin-bar nav { display: flex; gap: 1.2rem; flex-wrap: wrap; flex: 1; }
.inline-form { display: inline-flex; gap: .6rem; align-items: center; margin: 0; }
.admin-bar .button-quiet { color: #fff; border-color: #fff; }
.admin-bar .button-quiet:hover { background: #fff; color: var(--slate); }
.admin-wrap { padding-top: 1.25rem; padding-bottom: 3rem; max-width: 980px; }
.admin h1 { font-size: 1.6rem; }
.admin h2 { font-size: 1.15rem; }
.meta { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: .92rem; color: var(--muted); }
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
.tabs a { padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); text-decoration: none; font-size: .92rem; }
.tabs a.active { background: var(--slate); color: #fff; border-color: var(--slate); }
.count { background: var(--coral-dark); color: #fff; border-radius: 999px; padding: 0 .5rem; margin-left: .3rem; font-size: .8rem; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: .15rem .6rem; border-radius: 999px; background: #e4dccd; color: var(--text); font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
.badge-published { background: #dcebdc; color: #1f3d1f; }
.badge-rejected, .badge-unpublished { background: #f3d9d2; color: #5a1f14; }
.badge-pending_review, .badge-fact_check_required, .badge-revision_requested { background: #f5e6c8; color: #5a4210; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--paper); font-size: .95rem; }
.admin-table th, .admin-table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--slate); font-size: .85rem; }
.action-form { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.action-form h3 { margin-bottom: .6rem; }
details { margin: .6rem 0; }
summary { cursor: pointer; font-weight: 600; color: var(--slate); }
.login { max-width: 420px; margin-left: auto; margin-right: auto; margin-top: 3rem; }
.mail-body { white-space: pre-wrap; font-family: Consolas, monospace; font-size: .9rem; background: #fff; padding: .8rem; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }

@media (max-width: 640px) {
  .admin-table thead { position: absolute; left: -9999px; }
  .admin-table tr { display: block; border-bottom: 2px solid var(--line); padding: .4rem 0; }
  .admin-table td { display: block; border: 0; padding: .2rem .7rem; }
  .admin-table td::before { content: attr(data-label) ": "; font-weight: 700; color: var(--slate); }
  .story-page { padding: 1.1rem; }
}

/* Quiet word counter under the story text area */
.wordcount { color: var(--muted); font-size: .85rem; margin: .25rem 0 0; text-align: right; }
.wordcount.over { color: #8a2a1a; font-weight: 600; }
