/* Montgomeryshire Genealogical Society - Cymdeithas Achyddol Maldwyn
   One stylesheet for the public site and the members' area.
   Palette: Welsh slate, lichen and moss on stone-white. */

:root {
  --slate:      #26323b;   /* text, header, the tablet */
  --slate-2:    #3a4853;
  --slate-soft: #5d6b76;   /* secondary text */
  --stone:      #eef0ed;   /* panels */
  --paper:      #fbfbf9;   /* page */
  --rule:       #cfd5d1;
  --moss:       #3d5e34;   /* links, buttons */
  --moss-dark:  #2c4526;
  --lichen:     #b9c48d;   /* highlights on slate */
  --warn:       #8a5a12;
  --danger:     #9b2c24;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --sans:  "Gill Sans Nova", "Gill Sans", Seravek, "Segoe UI", Ubuntu, Calibri, "Helvetica Neue", Arial, sans-serif;

  --measure: 68ch;
  --map-strength: 0.16;    /* how visible the old map is: 0 = hidden, 1 = full strength */
  --radius: 4px;
}

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

html { font-size: 112.5%; -webkit-text-size-adjust: 100%; }     /* 18px base */
body {
  margin: 0;
  background: var(--paper);
  color: var(--slate);
  font-family: var(--sans);
  line-height: 1.55;
}
img { max-width: 100%; height: auto; }

/* The old county map, as a faint watermark behind every page */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url(/gifs/background.jpg) center top / cover no-repeat;
  opacity: var(--map-strength);
  filter: grayscale(30%);
}

a { color: var(--moss); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--moss-dark); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid #e2a41b; outline-offset: 2px; border-radius: 2px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; color: var(--slate); }
h1 { font-size: 2.1rem; margin: 0 0 0.6em; letter-spacing: -0.005em; }
h2 { font-size: 1.45rem; margin: 1.8em 0 0.5em; }
h3 { font-size: 1.15rem; margin: 1.5em 0 0.4em; }
p, ul, ol { margin: 0 0 1em; }
li { margin-bottom: 0.35em; }

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 10; background: #fff; padding: 0.5rem 1rem; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header (white banner, as on the previous site) ---------- */
.site-header { background: #fff; color: var(--slate); }
.header-inner { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; }
.brand { display: block; line-height: 0; }
.brand-banner { display: block; width: auto; height: auto; max-height: 160px; max-width: 100%; }
.login-box {
  flex: none; display: inline-flex; align-items: center; gap: 0.45rem;
  background: #fff; border: 1px solid #4a584a; padding: 0.3rem 0.6rem;
  color: var(--moss); text-decoration: none; font-size: 1rem; margin-top: 0.2rem;
}
.login-box:hover { background: var(--stone); color: var(--moss-dark); }
.login-box img { height: 29px; width: auto; }

.site-nav { background: var(--slate-2); }
.site-nav ul { list-style: none; margin: 0 auto; padding: 0; display: flex; flex-wrap: wrap; }
.site-nav li { margin: 0; }
.site-nav a {
  display: block; padding: 0.6rem 0.85rem; color: #e8ece9; text-decoration: none; font-size: 0.94rem;
  border-bottom: 3px solid transparent;
}
.site-nav a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.site-nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--lichen); }

/* ---------- the slate tablet (home page hero) ---------- */
.tablet-band { background: rgba(238, 240, 237, 0.82); border-bottom: 1px solid var(--rule); padding: 2.6rem 0 2.8rem; }
.tablet-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 2.5rem; align-items: center; }
.tablet {
  position: relative;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.06), transparent 60%),
    repeating-linear-gradient(176deg, rgba(255,255,255,0.025) 0 2px, transparent 2px 7px),
    #303d46;
  color: #dfe5e1;
  border-radius: 46% 46% 6px 6px / 22% 22% 6px 6px;   /* round-headed headstone */
  padding: 3.2rem 2.2rem 2.4rem;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), inset 0 -18px 30px rgba(0,0,0,0.25);
}
.tablet::after {    /* incised border line, as on carved slate */
  content: ""; position: absolute; inset: 14px;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 46% 46% 3px 3px / 21% 21% 3px 3px;
  pointer-events: none;
}
.tablet h1, .tablet p { color: inherit; position: relative; z-index: 1; }
.tablet .carved {
  font-family: var(--serif); font-weight: 600; margin: 0;
  font-size: clamp(1.7rem, 3.4vw, 2.6rem); line-height: 1.12; letter-spacing: 0.02em;
  color: #e9eee9;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.12);   /* incised */
}
.tablet .carved-cy {
  font-family: var(--serif); font-style: italic; font-size: clamp(1.15rem, 2.2vw, 1.55rem);
  color: var(--lichen); margin: 0.5em 0 1.1em;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.5);
}
.tablet .tablet-line { font-family: var(--serif); font-size: 1.02rem; margin: 0; color: #c9d1cc; }
.tablet .founded { display: block; margin-top: 1.1rem; font-family: var(--serif); letter-spacing: 0.3em; color: #9fab9f; font-size: 0.95rem; }

/* model gravestone on the Welsh language page */
.tablet-stone { padding: 3rem 1.6rem 2.2rem; }
.tablet-stone .stone-line {
  font-family: var(--serif); color: #e2e8e3; margin: 0 0 0.85rem; line-height: 1.35; font-size: 1.02rem;
  text-shadow: 0 -1px 0 rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.1);
}
.tablet-stone .stone-small { font-size: 0.9rem; letter-spacing: 0.06em; margin-bottom: 0.2rem; color: #c3ccc6; }
.tablet-stone .stone-name { font-size: 1.55rem; font-weight: 600; letter-spacing: 0.04em; margin-bottom: 0.3rem; }
.tablet-stone .stone-verse { font-style: italic; color: var(--lichen); margin: 1.2rem 0 0; }
.stone-caption { text-align: center; margin-top: 0.6rem; }
.ledger.welsh td[lang="cy"] { font-family: var(--serif); font-size: 1.05rem; width: 52%; }

.hero-copy .lede { font-size: 1.2rem; }
.hero-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1.4rem; }

/* ---------- page body ---------- */
.page-head { padding: 2.2rem 0 0.4rem; }
.page-head .lede { max-width: var(--measure); }
.lede { font-size: 1.12rem; color: var(--slate-soft); }
.content { padding-bottom: 3rem; }
.tablet-band + .content { padding-top: 2.4rem; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 3rem; align-items: start; }
.prose { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }

.aside-box { background: var(--stone); border-left: 4px solid var(--moss); padding: 1.1rem 1.25rem; margin-bottom: 1.5rem; border-radius: 0 var(--radius) var(--radius) 0; }
.aside-box h2, .aside-box h3 { margin-top: 0; font-size: 1.15rem; }
.aside-box p:last-child, .aside-box ul:last-child { margin-bottom: 0; }

.news { list-style: none; padding: 0; margin: 0; }
.news li { padding: 0.75rem 0; border-top: 1px solid var(--rule); margin: 0; }
.news li:first-child { border-top: 0; padding-top: 0; }
.news time { display: block; font-size: 0.85rem; color: var(--slate-soft); }

figure { margin: 1.5rem 0; }
figcaption { font-size: 0.9rem; color: var(--slate-soft); margin-top: 0.4rem; }
.photo { border-radius: var(--radius); display: block; }

.ledger { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1.5rem; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { text-align: left; padding: 0.55rem 0.8rem 0.55rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger th { font-weight: 600; font-size: 0.92rem; color: var(--slate-soft); }
.ledger td.amount { white-space: nowrap; }

.contact-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0 2rem; }
.contact-list li { border-top: 1px solid var(--rule); padding: 0.9rem 0 1rem; margin: 0; }
.contact-list .role { font-family: var(--serif); font-weight: 600; font-size: 1.08rem; display: block; }

.link-dir dt { font-family: var(--serif); font-weight: 600; font-size: 1.08rem; margin-top: 1.2rem; }
.link-dir dd { margin: 0.2rem 0 0; }

.recent-issues { margin-top: 2.5rem; padding-top: 0.5rem; border-top: 1px solid var(--rule); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 1rem; list-style: none; padding: 0; }
.thumbs li { margin: 0; }
.thumbs img { border: 1px solid var(--rule); border-radius: 2px; display: block; }
.thumbs span { display: block; font-size: 0.88rem; color: var(--slate-soft); margin-top: 0.3rem; }

.map { width: 100%; height: 360px; border: 0; border-radius: var(--radius); }

.crumbs { margin: 0 0 0.3rem; font-size: 0.92rem; }
.filter-label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
#parish-filter { max-width: 22rem; }
.ledger.codes td:first-child { width: 5.5rem; font-variant-numeric: normal; letter-spacing: 0.04em; }
.ledger tr[hidden] { display: none; }

/* ---------- photo galleries ---------- */
.gallery-folders, .gallery-grid { list-style: none; padding: 0; margin: 0 0 2rem; display: grid; gap: 1.2rem; }
.gallery-folders { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.gallery-grid { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
.gallery-folders li, .gallery-grid li { margin: 0; }
.gallery-folders a { display: block; text-decoration: none; background: #fff; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; color: var(--slate); }
.gallery-folders a:hover { border-color: var(--moss); }
.gallery-folders img, .gallery-folders .no-cover { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--stone); }
.folder-name { display: block; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; padding: 0.7rem 0.9rem 0; }
.folder-count { display: block; font-size: 0.88rem; color: var(--slate-soft); padding: 0 0.9rem 0.8rem; }
.gallery-grid a { display: block; border-radius: 4px; overflow: hidden; background: var(--stone); }
.gallery-grid img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.gallery-grid a:hover img { opacity: 0.9; }
.gallery-grid span { display: block; font-size: 0.88rem; color: var(--slate-soft); margin-top: 0.35rem; }

dialog.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; overflow: visible; }
dialog.lightbox::backdrop { background: rgba(20, 26, 30, 0.9); }
.lightbox figure { margin: 0; text-align: center; }
.lightbox img { max-width: 92vw; max-height: 84vh; width: auto; height: auto; display: block; margin: 0 auto; border-radius: 3px; }
.lightbox figcaption { color: #e6ebe7; margin-top: 0.6rem; font-size: 0.95rem; white-space: pre; }
.lightbox button {
  position: fixed; background: rgba(0,0,0,0.45); color: #fff; border: 1px solid rgba(255,255,255,0.4);
  width: 3rem; height: 3rem; border-radius: 50%; font-size: 1.8rem; line-height: 1; cursor: pointer;
}
.lightbox button:hover { background: rgba(0,0,0,0.7); }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-close { right: 1rem; top: 1rem; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-block; font: inherit; font-size: 1rem; line-height: 1.2; cursor: pointer;
  background: var(--moss); color: #fff; border: 1px solid var(--moss); border-radius: var(--radius);
  padding: 0.65rem 1.2rem; text-decoration: none;
}
.btn:hover { background: var(--moss-dark); border-color: var(--moss-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--moss); }
.btn-ghost:hover { background: var(--stone); color: var(--moss-dark); }
.btn-small { font-size: 0.88rem; padding: 0.4rem 0.8rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #7c211b; border-color: #7c211b; }
.tablet-band .btn-ghost { border-color: var(--moss); }

.form label { display: block; font-weight: 600; margin: 1rem 0 0.3rem; }
.form label.check { font-weight: normal; display: flex; gap: 0.5rem; align-items: flex-start; }
.form label.check input { margin-top: 0.3rem; }
.hint { font-weight: normal; color: var(--slate-soft); font-size: 0.9rem; }
input[type=text], input[type=search], input:not([type]), input[type=email], input[type=password], input[type=file], select, textarea {
  font: inherit; color: inherit; width: 100%; max-width: 32rem;
  padding: 0.6rem 0.7rem; border: 1px solid #9aa5a0; border-radius: var(--radius); background: #fff;
}
textarea { max-width: 100%; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--moss); }
.form .btn { margin-top: 1.3rem; }
form.inline { display: inline; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0 0 1rem; }
.toolbar input, .toolbar select { width: auto; flex: 1 1 14rem; max-width: 22rem; padding: 0.45rem 0.6rem; }
.toolbar .btn { margin: 0; }

/* ---------- members' area & admin ---------- */
.app-main { padding: 1.8rem 0 3rem; min-height: 60vh; }
.card { background: #fff; border: 1px solid var(--rule); border-radius: 6px; padding: 1.4rem 1.5rem; margin-bottom: 1.5rem; }
.card > h1:first-child, .card > h2:first-child { margin-top: 0; }
.card-narrow { max-width: 34rem; }
.notice-board { border-left: 4px solid var(--moss); }
.account { background: var(--stone); border-color: var(--stone); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.5rem; align-items: start; }
.members-grid { grid-template-columns: minmax(0, 1.6fr) minmax(16rem, 1fr); }
.whoami { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; font-size: 0.92rem; color: var(--slate-soft); margin-bottom: 1.2rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--rule); }
.notice { padding: 0.8rem 1rem; border-radius: var(--radius); margin-bottom: 1.2rem; }
.notice-ok { background: #e5efe0; border: 1px solid #a9c49d; }
.notice-error { background: #f8e6e3; border: 1px solid #dba59e; }
.small { font-size: 0.9rem; color: var(--slate-soft); }
.muted { color: var(--slate-soft); }
.linklist { padding-left: 1.1rem; }
.filelist { list-style: none; padding: 0; }
.filelist li { padding: 0.45rem 0; border-bottom: 1px solid var(--stone); margin: 0; }
.filelist .meta { font-size: 0.82rem; color: var(--slate-soft); margin-left: 0.4rem; white-space: nowrap; }
.card h3 { font-size: 1.05rem; margin-top: 1.2rem; }

.adminnav { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 1.6rem; }
.adminnav a { padding: 0.45rem 0.85rem; border-radius: var(--radius); text-decoration: none; background: var(--stone); color: var(--slate); font-size: 0.93rem; }
.adminnav a[aria-current="page"] { background: var(--slate); color: #fff; }
.stats { display: flex; flex-wrap: wrap; gap: 0.5rem 1.6rem; color: var(--slate-soft); }
.stats strong { color: var(--slate); font-size: 1.15rem; }
.tablewrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.93rem; background: #fff; }
table.data th, table.data td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data thead th { background: var(--stone); font-weight: 600; }
table.data tr.warn td { background: #fbf3e4; }
.badge { display: inline-block; font-family: var(--sans); font-size: 0.78rem; font-weight: 600; padding: 0.12rem 0.5rem; border-radius: 99px; vertical-align: middle; }
.badge-ok { background: #e1ecdc; color: var(--moss-dark); }
.badge-warn { background: #f6e8cc; color: var(--warn); }
.badge-off { background: #ececec; color: #555; }
.temp-pw { border: 2px dashed var(--moss); }
.pw { font-family: var(--serif); font-size: 1.4rem; letter-spacing: 0.04em; }
td.pw { font-size: 1rem; }
.stack p { margin-bottom: 1rem; }
.danger { border-top: 1px solid var(--rule); margin-top: 1rem; padding-top: 0.5rem; }
.danger h3 { color: var(--danger); }
code { font-size: 0.9em; background: var(--stone); padding: 0.05em 0.3em; border-radius: 3px; }

/* ---------- footer ---------- */
.site-footer { background: var(--slate); color: #cfd6d2; font-size: 0.92rem; padding: 2rem 0; margin-top: 2rem; }
.site-footer a { color: #fff; }
.site-footer p { margin: 0 0 0.4rem; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 2rem; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 0.3rem; }
.footer-name { font-family: var(--serif); font-size: 1.05rem; color: #fff; }
.footer-name span { display: block; color: var(--lichen); font-style: italic; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .tablet-layout, .columns, .members-grid, .footer-grid { grid-template-columns: 1fr; }
  .tablet { padding: 2.6rem 1.4rem 2rem; }
  h1 { font-size: 1.75rem; }
  .site-nav a { padding: 0.55rem 0.65rem; }
}
@media (max-width: 520px) {
  .header-inner { flex-direction: column-reverse; align-items: stretch; }
  .login-box { align-self: flex-end; font-size: 0.9rem; }
  .brand-banner { max-height: 120px; }
  .site-nav a { padding: 0.5rem 0.55rem; font-size: 0.9rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print {
  body::before { display: none; }
  .site-header, .site-nav, .site-footer, .hero-actions, .whoami form { display: none; }
  body { background: #fff; }
}
