/* =========================================================================
   kortuem.com site stylesheet
   Visual style only. Structure and interactivity live in HTML per D4.
   Supports two document patterns:
     technical-document: .layout grid, aside.toc, main.doc, header.doc-header,
                         footer.page-footer (see notes/aira/)
     essay:              <article>, nav.top, nav.toc, header.doc, <footer>
                         (see notes/agentic-design/)
   ========================================================================= */

/* ---- CSS custom properties (palette and type stacks) ------------------ */
:root {
  /* palette */
  --bg:         #faf8f4;
  --bg-soft:    #f3f0e9;
  --ink:        #1a1a1a;
  --ink-soft:   #3a3a3a;
  --ink-muted:  #8a8580;
  --rule:       #d6d2c8;
  --accent:     #2c5878;
  --code-bg:    #ece8df;

  /* layout */
  --max-prose:  38rem;            /* technical-document default; essays hard-code 36rem */

  /* type stacks */
  --serif: "Iowan Old Style", "Charter", "Source Serif Pro", Georgia,
           "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
           system-ui, sans-serif;
  --mono:  ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---- Reset and base --------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* =========================================================================
   PATTERN: technical-document
   ========================================================================= */

/* ---- Layout: sidebar + main on desktop, single column on mobile ------ */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 76rem;
  margin: 0 auto;
}
@media (min-width: 960px) {
  .layout {
    grid-template-columns: 16rem 1fr;
    gap: 3rem;
  }
}

/* ---- Sidebar TOC (sticky on desktop) --------------------------------- */
aside.toc {
  padding: 2rem 1.5rem;
  font-size: 0.875rem;
}
@media (min-width: 960px) {
  aside.toc {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
    padding: 3rem 0 3rem 1.5rem;
    border-right: 1px solid var(--rule);
  }
}
aside.toc .home {
  display: inline-block;
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  margin-bottom: 2rem;
  font-size: 0.875rem;
}
aside.toc .home:hover { color: var(--accent); border-bottom-color: var(--accent); }
aside.toc h2 {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
  margin: 0 0 1rem;
}
aside.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}
aside.toc > ol > li {
  margin-bottom: 0.4rem;
}
aside.toc a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  display: inline-block;
  line-height: 1.4;
  padding: 0.1rem 0;
}
aside.toc a:hover { color: var(--accent); border-bottom-color: var(--accent); }
aside.toc ol ol {
  margin: 0.25rem 0 0.5rem 1rem;
  font-size: 0.8125rem;
}
aside.toc ol ol a { color: var(--ink-muted); }
aside.toc .toc-section {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
}
aside.toc details summary {
  cursor: pointer;
  list-style: none;
}
aside.toc details summary::-webkit-details-marker { display: none; }
aside.toc details summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.4em;
  font-size: 0.7em;
  color: var(--ink-muted);
  transition: transform 0.15s;
}
aside.toc details[open] summary::before {
  transform: rotate(90deg);
}

/* ---- Main content container (technical-document) --------------------- */
main.doc {
  padding: 3rem 1.5rem 4rem;
  min-width: 0;
}
@media (min-width: 960px) {
  main.doc { padding: 3rem 2rem 4rem 0; }
}
.prose {
  max-width: var(--max-prose);
}

/* =========================================================================
   PATTERN: essay
   ========================================================================= */

/* ---- Top nav (essay back-link) --------------------------------------- */
nav.top {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
  font-size: 0.875rem;
}
nav.top a {
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  letter-spacing: 0.02em;
}
nav.top a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- Article container (essay) --------------------------------------- */
article {
  max-width: 48rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  font-size: 1.125rem;
  line-height: 1.7;
}

/* ---- Figure (essay) -------------------------------------------------- */
article figure {
  margin: 2.5rem 0;
  text-align: center;
}
article figure img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
article figcaption {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-style: italic;
  color: var(--ink-muted);
  line-height: 1.5;
  margin-top: 0.75rem;
  text-align: left;
}

/* ---- Inline TOC (essay) ---------------------------------------------- */
nav.toc {
  margin: 0 0 3rem;
  padding: 1.25rem 1.5rem;
  background: rgba(214, 210, 200, 0.25);
  border-left: 2px solid var(--accent);
  font-size: 0.9375rem;
}
nav.toc h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin: 0 0 0.75rem;
  border: none;
  padding: 0;
}
nav.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc;
}
nav.toc li {
  counter-increment: toc;
  margin: 0.4rem 0;
}
nav.toc li::before {
  content: counter(toc) ". ";
  color: var(--ink-muted);
  margin-right: 0.35rem;
}
nav.toc a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
nav.toc a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* =========================================================================
   SHARED: document header (used by both patterns via header.doc-header
   for technical-document and header.doc for essay)
   ========================================================================= */
header.doc-header,
header.doc {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
}
header.doc-header h1,
header.doc h1 {
  font-family: var(--sans);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}
header.doc-header .subtitle,
header.doc .subtitle {
  font-family: var(--sans);
  font-size: 1.0625rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0 0 1.5rem;
}
header.doc-header .meta,
header.doc .meta {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--ink-muted);
  margin: 0;
  line-height: 1.6;
}
header.doc .meta {
  line-height: 1.5;
}
header.doc-header .meta strong,
header.doc .meta strong {
  color: var(--ink-soft);
  font-weight: 600;
}

/* =========================================================================
   SHARED: typography
   ========================================================================= */

/* ---- Headings -------------------------------------------------------- */
/* Per CONVENTIONS.md: headings, navigation, TOC, meta, and footers in
   sans-serif. Body prose stays serif. Sans signals structure; serif
   signals prose. */
h2, h3, h4 {
  font-family: var(--sans);
}
aside.toc,
nav.toc,
nav.top,
footer.page-footer,
footer,
section.references h2 {
  font-family: var(--sans);
}
h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 3.5rem 0 1.25rem;
  color: var(--ink);
  line-height: 1.3;
  scroll-margin-top: 1rem;
}
article h2 {
  font-size: 1.375rem;
  margin: 3.5rem 0 1rem;
  padding-top: 0.5rem;
}
h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 2.25rem 0 0.75rem;
  color: var(--ink);
  scroll-margin-top: 1rem;
}
h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 1.5rem 0 0.5rem;
}

/* ---- Body text ------------------------------------------------------- */
p {
  margin: 0 0 1.1rem;
  color: var(--ink-soft);
}
article p {
  margin: 0 0 1.25rem;
}
ul, ol {
  margin: 0 0 1.25rem;
  padding-left: 1.5rem;
  color: var(--ink-soft);
}
li { margin-bottom: 0.4rem; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(44, 88, 120, 0.3);
  transition: border-color 0.15s ease;
}
a:hover { border-bottom-color: var(--accent); }

cite {
  font-style: normal;
  color: var(--accent);
}
cite a {
  color: var(--accent);
  border-bottom: 1px dotted rgba(44, 88, 120, 0.4);
}

/* ---- Code (inline and block) ----------------------------------------- */
code, pre {
  font-family: var(--mono);
  font-size: 0.875em;
}
code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: var(--ink);
}
pre {
  background: var(--code-bg);
  padding: 1rem 1.25rem;
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.5;
  margin: 1.25rem 0;
  font-size: 0.8125rem;
}
pre code {
  background: transparent;
  padding: 0;
}

/* ---- Tables ---------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9375rem;
  line-height: 1.5;
}
th, td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--ink-muted);
  background: rgba(214, 210, 200, 0.2);
}
td code {
  font-size: 0.8125em;
  background: var(--code-bg);
}

/* ---- Blockquotes ----------------------------------------------------- */
blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.25rem 0 0.25rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---- Labeled callouts (e.g., AIRA risk dimensions R1-R12) ----------- */
.risk-item {
  margin-bottom: 1rem;
  padding-left: 0;
}
.risk-item .label {
  font-weight: 600;
  color: var(--ink);
  font-style: normal;
}

/* ---- Collapsibles (long sections, appendices) ------------------------ */
details.section {
  margin: 1.5rem 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg-soft);
}
details.section > summary {
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  font-size: 0.9375rem;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.6em;
  font-size: 0.8em;
  color: var(--ink-muted);
  transition: transform 0.15s;
}
details.section[open] > summary::before {
  transform: rotate(90deg);
}
details.section[open] > summary {
  border-bottom: 1px solid var(--rule);
}
details.section .content {
  padding: 1.25rem 1.25rem 0.25rem;
}

/* ---- References section --------------------------------------------- */
section.references {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
section.references h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin: 0 0 1.25rem;
  border: none;
}
section.references ol {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
}
section.references li {
  margin-bottom: 1rem;
  padding-left: 1.5em;
  text-indent: -1.5em;
  color: var(--ink-soft);
}
section.references li a {
  word-break: break-word;
}

/* =========================================================================
   FOOTERS: two variants
   ========================================================================= */

/* Technical-document footer (full-width, used after main.doc) */
footer.page-footer {
  margin-top: 3rem;
  padding: 2rem 1.5rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule);
  text-align: center;
}

/* Essay footer (constrained to prose width, used after article) */
footer:not(.page-footer) {
  max-width: 36rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule);
  text-align: center;
}

footer a {
  color: var(--ink-muted);
  border-bottom-color: rgba(138, 133, 128, 0.4);
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 480px) {
  main.doc { padding: 2rem 1.25rem 3rem; }
  article { padding: 2rem 1.25rem 3rem; line-height: 1.65; }
  header.doc-header h1,
  header.doc h1 { font-size: 1.625rem; }
  h2 { font-size: 1.25rem; }
  article h2 { font-size: 1.25rem; margin-top: 2.5rem; }
  body { font-size: 1rem; }
}

/* =========================================================================
   PRINT
   ========================================================================= */

@media print {
  body { background: white; }
  aside.toc, footer.page-footer, nav.top, nav.toc, footer { display: none; }
  main.doc { padding: 0; }
  article { padding: 0; max-width: none; }
  .prose { max-width: none; }
  a { color: var(--ink); border-bottom: none; }
  details.section { border: none; background: none; }
  details.section[open] > summary { border-bottom: none; }
  details.section > summary::before { display: none; }
}

/* =========================================================================
   PATTERN: /projects/ grid and case-study
   ========================================================================= */

/* ---- Grid index at /projects/ ---------------------------------------- */
ul.projects-grid {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 2.5rem;
}
.project-card > a {
  display: block;
  color: inherit;
  text-decoration: none;
  border-bottom: none;
}
.project-card > a:hover .project-title {
  color: var(--accent);
}
.project-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  margin-bottom: 0.75rem;
}
.project-card .project-title {
  font-family: var(--sans);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.375rem;
  line-height: 1.3;
  transition: color 0.15s ease;
}
.project-card .project-descriptor {
  font-family: var(--serif);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 0.5rem;
}
.project-card .project-date {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin: 0;
  letter-spacing: 0.04em;
}

/* ---- Piece embed on case-study pages --------------------------------- */
.piece-embed {
  margin: 2.5rem calc(-1 * (max(0px, (100vw - 60rem) / 2))) 2.5rem calc(-1 * (max(0px, (100vw - 60rem) / 2)));
  max-width: 60rem;
  margin-left: auto;
  margin-right: auto;
  background: #000;
  border: 1px solid var(--rule);
}
.piece-embed iframe {
  display: block;
  width: 100%;
  height: min(85vh, 800px);
  border: 0;
  background: #000;
}
.piece-embed-caption {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--ink-muted);
  text-align: center;
  margin: 0.75rem 0 0;
  padding: 0 1rem 0.75rem;
  background: transparent;
}
.piece-embed-caption a {
  color: var(--ink-muted);
  border-bottom: 1px solid rgba(138, 133, 128, 0.4);
}
.piece-embed-caption a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

@media (max-width: 480px) {
  ul.projects-grid { gap: 1.75rem; }
  .piece-embed iframe { height: min(75vh, 600px); }
}
