/*
 * Martin S. Kaplan — Digital Journal
 * Direction: a family archive / bound memoir. Warm paper, ink type,
 * Baskerville for reading, small-caps labels for dates and kinds,
 * one oxblood accent reserved for "you are here" and small marks.
 */

:root {
  /* Color — named by purpose */
  --paper: #f6f2ea;          /* page background */
  --paper-deep: #ece5d8;     /* footer, quiet bands */
  --sheet: #fffdf9;          /* reading surfaces */
  --ink: #23262b;            /* body text, headings */
  --ink-soft: #4a4d52;       /* secondary text */
  --muted: #74706a;          /* labels, meta (AA on paper) */
  --rule: #d9d1c3;           /* hairlines */
  --accent: #8e2f24;         /* oxblood: current page, numerals */
  --link: #23262b;
  --link-underline: #b9ad99;
  --focus: #1f5f8b;

  /* Type */
  --serif: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --sans: 'Source Sans Pro', 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;

  /* Layout */
  --wrap: 1120px;
  --measure: 40rem;          /* comfortable reading line */
  --gutter: clamp(1rem, 4vw, 2rem);
  --radius: 2px;

  /* Legacy names still referenced by inline template styles */
  --primary-color: var(--ink);
  --accent-color: var(--accent);
  --border-color: var(--rule);
  --text-color: var(--ink);
  --light-text: var(--muted);
  --card-color: var(--sheet);
  --spacing-xs: .25rem; --spacing-sm: .5rem; --spacing-md: 1rem; --spacing-lg: 2rem; --spacing-xl: 3rem;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  overflow-wrap: break-word;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body > main { flex: 1 0 auto; width: 100%; }
h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  margin: 2rem 0 .75rem;
}
h1 { font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1rem; }
img { max-width: 100%; height: auto; }

a { color: var(--link); text-decoration: underline; text-decoration-color: var(--link-underline);
    text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

blockquote { margin: 1.5rem 0; padding-left: 1rem; border-left: 2px solid var(--rule); color: var(--ink-soft); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

.container { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
main.container { padding-bottom: 3rem; min-height: 40vh; }
main .container { padding: 0; }  /* templates nest a .container inside main */

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; }

/* Small-caps label used for dates, kinds, counts */
.label, .kicker {
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.kicker { display: block; margin-bottom: .5rem; }
.kicker .sep, .label .sep { margin: 0 .4em; color: var(--rule); }

/* ---------- Header ---------- */
.site-header { background: var(--paper); border-bottom: 1px solid var(--rule); }
.site-header .container { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; padding-top: 1.1rem; padding-bottom: 1.1rem; }
.site-title { font-family: var(--serif); font-size: 1.45rem; margin: 0; letter-spacing: -.01em; }
.site-title a { color: var(--ink); text-decoration: none; }
.main-navigation ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.4rem; }
.main-navigation a {
  font-weight: 600; font-size: .95rem; color: var(--ink-soft); text-decoration: none;
  padding: .3rem 0; border-bottom: 2px solid transparent;
}
.main-navigation a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.main-navigation a.active, .main-navigation a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Page header (list pages) ---------- */
.page-head { padding: 2.5rem 0 1rem; max-width: var(--measure); }
.page-head h1 { margin: 0 0 .5rem; }
.page-head .lead, .page-head p { color: var(--ink-soft); font-size: 1.05rem; margin: 0; }

/* Filter tabs (replace red button rows) */
.filters { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: 1.25rem 0 .5rem; padding-bottom: .5rem; border-bottom: 1px solid var(--rule); }
.filters a { font-weight: 600; font-size: .95rem; color: var(--muted); text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; margin-bottom: -.55rem; }
.filters a:hover { color: var(--ink); }
.filters a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* Ruled index rows (memoirs, videos, publications) */
.rows { list-style: none; margin: 0; padding: 0; max-width: 62rem; }
.filters { max-width: 62rem; }
/* Source Sans' latin subset has no arrow glyphs: draw them from a system font */
.arr { font-family: inherit; }
.row-item { display: grid; grid-template-columns: 7.5rem 1fr auto; gap: .25rem 1.25rem; align-items: baseline; padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.row-item .row-when { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-item .row-title { font-family: var(--serif); font-size: 1.08rem; line-height: 1.4; }
.row-item .row-title a { text-decoration: none; }
.row-item .row-title a:hover { text-decoration: underline; }
.row-item .row-aside { font-size: .85rem; color: var(--muted); white-space: nowrap; text-align: right; }
.row-item .row-note { grid-column: 2 / -1; color: var(--ink-soft); font-size: .95rem; margin: 0; }
.row-item.numbered { grid-template-columns: 2.5rem 1fr auto; }
.row-num { font-family: var(--serif); color: var(--accent); font-size: 1rem; font-variant-numeric: oldstyle-nums; }

/* ---------- Pagination ---------- */
.pager { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: .25rem; margin: 2.5rem 0 0; padding: 0; list-style: none; }
.pager a, .pager span { display: inline-block; min-width: 2.4rem; padding: .4rem .7rem; text-align: center; text-decoration: none; color: var(--ink-soft); border: 1px solid transparent; border-radius: var(--radius); }
.pager a:hover { border-color: var(--rule); color: var(--ink); background: var(--sheet); }
.pager .current { color: var(--ink); border-color: var(--ink); font-weight: 600; }
.pager .disabled { color: var(--rule); }
.pager .arr { display: inline; min-width: 0; padding: 0; border: 0; }

/* ---------- Home ---------- */
.home-intro { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: clamp(1.5rem, 5vw, 4rem); align-items: center; padding: clamp(2rem, 5vw, 4rem) 0 2.5rem; }
.portrait { margin: 0; }
.portrait img { display: block; width: 100%; height: auto; background: var(--sheet); padding: .6rem; border: 1px solid var(--rule); box-shadow: 0 1px 0 var(--rule); }
.home-copy .home-quote { font-family: var(--serif); font-style: italic; font-size: clamp(1.4rem, 1rem + 1.8vw, 2.1rem); line-height: 1.3; margin: .25rem 0 1.25rem; color: var(--ink); }
.home-copy p { color: var(--ink-soft); font-size: 1.05rem; max-width: 36rem; }

.home-section { border-top: 1px solid var(--rule); padding: 2rem 0 .5rem; }
.home-section > h2 { font-size: 1rem; margin: 0 0 1rem; font-family: var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.recent { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.5rem 2.5rem; }
.recent-item h3 { margin: .1rem 0 .4rem; font-size: 1.15rem; line-height: 1.4; }
.recent-item h3 a { text-decoration: none; }
.recent-item h3 a:hover { text-decoration: underline; }
.recent-item p { color: var(--ink-soft); margin: 0; font-size: .95rem; }

.sections { list-style: none; margin: 0; padding: 0; }
.sections li { border-bottom: 1px solid var(--rule); }
.sections li:last-child { border-bottom: 0; }
.sections a { display: grid; grid-template-columns: 11rem 1fr auto; gap: 1rem; align-items: baseline; padding: 1rem 0; text-decoration: none; }
.sections .s-name { font-family: var(--serif); font-size: 1.3rem; font-weight: 700; }
.sections .s-desc { color: var(--ink-soft); }
.sections .s-count { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.sections a:hover .s-name { color: var(--accent); }

/* ---------- Reading pages (memoir, about) ---------- */
.reading { background: var(--sheet); border: 1px solid var(--rule); margin: 2rem auto 0; padding: clamp(1.25rem, 5vw, 3.5rem) clamp(1.1rem, 6vw, 4.5rem); max-width: 52rem; }
.reading-head { margin-bottom: 2rem; }
.reading-head h1 { margin: 0 0 .75rem; }
.reading-meta { color: var(--muted); font-size: .95rem; }
.prose { font-family: var(--serif); font-size: 1.06rem; line-height: 1.85; max-width: var(--measure); }
.prose p { margin: 0 0 1.15em; }
.prose img { margin: 1.5rem 0; }
.prose blockquote { border-left: 0; padding: 0; text-align: inherit; }
/* Each memoir opens with Marty's own heading line (title, date, revision): set it as a quiet dateline */
.memoir-body > :first-child { font-family: var(--sans); font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); line-height: 1.5; margin-bottom: 1.75rem; font-weight: 600; }
.memoir-body > :first-child strong, .memoir-body > :first-child em { font-weight: 600; font-style: normal; }

.chapter-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: start; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.chapter-nav a { text-decoration: none; }
.chapter-nav .cn-label { display: block; }
.chapter-nav .cn-title { font-family: var(--serif); font-size: .98rem; line-height: 1.4; }
.chapter-nav a:hover .cn-title { text-decoration: underline; }
.chapter-nav .cn-next { text-align: right; }
.chapter-nav .cn-all { align-self: center; font-weight: 600; font-size: .9rem; white-space: nowrap; }

.reading-progress-container { position: fixed; top: 0; left: 0; width: 100%; height: 3px; background: transparent; z-index: 1000; }
.reading-progress-bar { height: 100%; width: 0; background: var(--accent); }

/* ---------- Video ---------- */
.video-page { max-width: 54rem; margin: 0 auto; padding-top: 2.5rem; }
.video-page h1 { margin: 0 0 .75rem; }
.video-player { margin: 1.5rem 0; }
.video-container { position: relative; aspect-ratio: 16 / 9; background: #111; border-radius: var(--radius); overflow: hidden; }
.video-container video, .video-container iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-container.is-placeholder { display: flex; align-items: center; justify-content: center; color: #bbb; }
.video-body { color: var(--ink-soft); max-width: var(--measure); }
.video-facts { margin: .25rem 0 0; color: var(--ink-soft); }
.video-facts dt { display: inline; font-weight: 600; color: var(--ink); }
.video-facts dd { display: inline; margin: 0; }
.related { margin-top: 3rem; border-top: 1px solid var(--rule); padding-top: 1.5rem; }
.related h2 { font-family: var(--sans); font-size: .9rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }

/* ---------- Photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); gap: 1.25rem; margin-top: 1.5rem; }
.photo { margin: 0; background: var(--sheet); border: 1px solid var(--rule); padding: .5rem; display: flex; flex-direction: column; align-self: start; }
.photo a { display: block; }
.photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-deep); }
.photo figcaption { padding: .55rem .15rem .1rem; font-size: .9rem; line-height: 1.4; color: var(--ink-soft); }
.photo figcaption strong { display: block; font-family: var(--serif); font-size: .95rem; color: var(--ink); font-weight: 700; }

/* ---------- Publications ---------- */
.pub-links { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .35rem; font-size: .95rem; font-weight: 600; }

/* ---------- About ---------- */
.about h1 { margin-top: 0; }
.about h2 { font-size: 1.2rem; margin-top: 2rem; }
.about ul { padding-left: 1.2rem; }
.about li { margin-bottom: .5rem; }
.about .credit { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--muted); font-family: var(--sans); font-size: .9rem; }

/* ---------- Footer ---------- */
.site-footer { background: var(--paper-deep); border-top: 1px solid var(--rule); margin-top: 3rem; padding: 2rem 0; font-size: .92rem; color: var(--ink-soft); }
.footer-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 1rem 2rem; }
.footer-name { font-family: var(--serif); font-weight: 700; color: var(--ink); font-size: 1.05rem; margin: 0; }
.footer-nav { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: 0; padding: 0; }
.footer-nav a { color: var(--ink-soft); }
.footer-bottom { margin-top: 1.25rem; color: var(--muted); font-size: .85rem; }

/* ---------- Buttons / forms (admin-facing bits, comments, password page) ---------- */
.btn { display: inline-block; font: 600 .95rem/1.2 var(--sans); padding: .55rem 1rem; border: 1px solid var(--ink); background: var(--ink); color: #fff; border-radius: var(--radius); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-outline, .btn-secondary, [class*="btn-outline-"] { background: transparent; color: var(--ink); }
.btn-outline:hover, .btn-secondary:hover, [class*="btn-outline-"]:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.disabled { opacity: .4; pointer-events: none; }
label { display: block; font-weight: 600; margin-bottom: .35rem; }
input[type="text"], input[type="email"], input[type="password"], textarea, select, .form-control {
  width: 100%; padding: .55rem .7rem; font: 1rem var(--sans); color: var(--ink); background: #fff; border: 1px solid var(--rule); border-radius: var(--radius);
}
.form-group, .mb-3 { margin-bottom: 1rem; }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 1rem; }
.tag, .badge { display: inline-block; font-size: .78rem; font-weight: 600; letter-spacing: .04em; padding: .15rem .55rem; border: 1px solid var(--rule); border-radius: 99px; color: var(--ink-soft); background: var(--sheet); text-decoration: none; }

/* ---------- Compatibility for remaining Bootstrap-style markup ----------
   (category/tag/search/album/publication detail and password pages)    */
.text-muted, .text-body-secondary { color: var(--muted) !important; }
.lead { font-size: 1.1rem; color: var(--ink-soft); }
.d-flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .align-items-center { align-items: center; } .align-items-baseline { align-items: baseline; }
.justify-content-between { justify-content: space-between; } .justify-content-center { justify-content: center; }
.w-100 { width: 100%; } .text-center { text-align: center; } .text-decoration-none { text-decoration: none; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .25rem; } .mb-2 { margin-bottom: .5rem; } .mb-4 { margin-bottom: 1.5rem; } .mb-5 { margin-bottom: 2.5rem; }
.mt-2 { margin-top: .5rem; } .mt-4 { margin-top: 1.5rem; } .mt-5 { margin-top: 2.5rem; } .me-1 { margin-right: .25rem; } .me-2 { margin-right: .5rem; } .ms-2 { margin-left: .5rem; }
.list-group { list-style: none; margin: 0; padding: 0; }
.list-group-item { padding: .75rem 0; border-bottom: 1px solid var(--rule); }
.card { background: var(--sheet); border: 1px solid var(--rule); margin-bottom: 1.5rem; }
.card-header, .card-body, .card-footer { padding: 1rem 1.25rem; }
.card-header { border-bottom: 1px solid var(--rule); }
.card-header.text-white, .card-header .text-white { color: var(--ink) !important; }
.card-img-top { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1.5rem; }
.alert { padding: 1rem 1.25rem; border: 1px solid var(--rule); background: var(--sheet); margin: 1rem 0; }
.bg-primary, .bg-secondary, .bg-info, .bg-success, .bg-danger { background: var(--sheet) !important; }
.fas, .far, .fab { display: none; } /* icon font is not loaded */
.display-4, .display-5 { font-size: inherit; }
.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: .25rem; list-style: none; padding: 0; margin: 2rem 0 0; }
.pagination .page-link { display: inline-block; padding: .4rem .7rem; text-decoration: none; }
.pagination .active .page-link { border: 1px solid var(--ink); }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  html { font-size: 16px; }
  .site-header .container { padding-top: .8rem; padding-bottom: .7rem; gap: .35rem; }
  .site-title { font-size: 1.25rem; }
  .main-navigation ul { gap: .1rem 1rem; }
  .main-navigation a { font-size: .9rem; }

  .home-intro { grid-template-columns: 1fr; text-align: left; padding-top: 1.5rem; }
  .portrait { max-width: 12rem; }
  .sections a { grid-template-columns: 1fr auto; }
  .sections .s-desc { grid-column: 1 / -1; grid-row: 2; font-size: .95rem; }

  .row-item { grid-template-columns: 1fr auto; padding: .85rem 0; }
  .row-item .row-when { grid-column: 1 / -1; order: -1; }
  .row-item .row-note { grid-column: 1 / -1; }
  .row-item.numbered { grid-template-columns: 2rem 1fr; }
  .row-item.numbered .row-aside { grid-column: 2; text-align: left; }

  .reading { margin-top: 1rem; border-left: 0; border-right: 0; }
  .prose { font-size: 1.02rem; line-height: 1.75; }
  .chapter-nav { grid-template-columns: 1fr 1fr; }
  .chapter-nav .cn-all { grid-column: 1 / -1; grid-row: 2; text-align: center; }

  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .photo { padding: .35rem; }
  .photo figcaption { font-size: .82rem; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-header, .site-footer, .chapter-nav, .filters, .pager, .reading-progress-container, .comments { display: none; }
  .reading { border: 0; padding: 0; margin: 0; max-width: none; }
  a { color: #000; text-decoration: none; }
}
