/* Designing Secure Software: site styles.
   Palette: Okabe-Ito blue and orange (distinguishable with all common
   colour-vision deficiencies). Links are always underlined so meaning
   never depends on colour alone. */

:root {
  --bg: #fdfcfa;
  --surface: #f3f1ec;
  --text: #1f2328;
  --muted: #5b6168;
  --border: #ddd8cf;
  --accent: #005a8f;        /* Okabe-Ito blue, darkened for AA contrast */
  --accent-hover: #003f66;
  --accent-soft: #e3eff7;
  --highlight: #b35a00;     /* Okabe-Ito orange, darkened for AA contrast */
  --code-bg: #f0eee9;
  --shadow: 0 6px 24px rgb(0 0 0 / 0.08);
  /* Content width: half of the old 44rem layout's side margins. */
  --measure: calc(50vw + 22rem);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans JP", sans-serif;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, "Noto Serif", "Noto Serif JP", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Source Code Pro", Menlo, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --surface: #1d2126;
    --text: #e6e3dd;
    --muted: #a3a9b0;
    --border: #343a41;
    --accent: #6cb6e8;
    --accent-hover: #9cd0f2;
    --accent-soft: #1d3446;
    --highlight: #f0b45a;
    --code-bg: #22272d;
    --shadow: 0 6px 24px rgb(0 0 0 / 0.4);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.7 var(--serif);
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; }

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

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--bg); padding: 0.5rem 1rem; z-index: 10; }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1rem; }

/* Header and navigation */
.site-header {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
}
.bar {
  max-width: var(--measure); margin: 0 auto; padding: 0.5rem 1rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--text); text-decoration: none; }
.brand img { border-radius: 4px; object-fit: cover; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 1rem; }
.brand small { color: var(--muted); font-size: 0.8rem; }

.menu > ul { display: flex; flex-wrap: wrap; gap: 0.15rem; list-style: none; margin: 0; padding: 0; }
.menu li { position: relative; }
.menu a, .menu summary {
  display: block; padding: 0.4rem 0.7rem; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 0.92rem; cursor: pointer;
}
.menu a:hover, .menu summary:hover, .menu details[open] > summary { background: var(--accent-soft); color: var(--accent-hover); }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; font-size: 0.75em; color: var(--muted); }
.menu details ul {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 13rem;
  list-style: none; margin: 0; padding: 0.35rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}

/* Main content */
main.wrap { padding-top: 2.5rem; padding-bottom: 3rem; }

.page-head { margin-bottom: 2rem; }
.page-head h1 { margin-bottom: 0.4rem; }

h1, h2, h3, h4, h5, h6 { font-family: var(--sans); line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 1rem; }
h2 { font-size: 1.5rem; margin: 2.4rem 0 0.8rem; }
h3 { font-size: 1.2rem; margin: 2rem 0 0.6rem; }
h4, h5, h6 { font-size: 1rem; margin: 1.6rem 0 0.5rem; }

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { position: relative; }
.anchor { color: var(--muted); text-decoration: none; opacity: 0; padding-left: 0.3rem; transition: opacity 0.15s; }
.prose :is(h1, h2, h3, h4, h5, h6):hover .anchor, .anchor:focus { opacity: 1; }

p, ul, ol, dl, blockquote, pre, table, figure { margin: 0 0 1.2rem; }
li { margin: 0.25rem 0; }
li > ul, li > ol { margin: 0.25rem 0 0; }

blockquote {
  margin-left: 0; padding: 0.6rem 1.1rem;
  border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 6px 6px 0;
}
blockquote > :last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

code, pre { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 1rem; border-radius: 8px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; padding: 0; }

table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: 0.95rem; }
th, td { border: 1px solid var(--border); padding: 0.4rem 0.7rem; text-align: left; vertical-align: top; }
th { background: var(--surface); font-family: var(--sans); }

.footnote-definition { font-size: 0.92rem; display: flex; gap: 0.5rem; }
.footnote-definition p { margin: 0; }

/* Metadata, tags */
.meta { font-family: var(--sans); font-size: 0.9rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font-family: var(--sans); font-size: 0.82rem; text-decoration: none;
  padding: 0.05rem 0.55rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
}
.tag:hover { border-color: var(--accent); }

/* Home page: the cover art floats right at half width; text flows beside it. */
.home p:has(> img:only-child) { float: right; width: 50%; margin: 0.3rem 0 1rem 2rem; }
.home p:has(> img:only-child) img { display: block; width: 100%; }

/* Listings */
.listing { margin-top: 2.5rem; clear: both; }
.listing h2 { margin-top: 0; }
.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { padding: 1rem 0; border-top: 1px solid var(--border); margin: 0; }
.post-list li:last-child { border-bottom: 1px solid var(--border); }
.post-title { font-family: var(--sans); font-weight: 600; font-size: 1.08rem; text-decoration: none; }
.post-title:hover { text-decoration: underline; }
.post-list time { display: block; font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
.post-list p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.97rem; }
.more { margin-top: 1rem; font-family: var(--sans); }

.tag-cloud { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.tag-cloud .count { color: var(--muted); font-family: var(--sans); font-size: 0.85rem; }

.pager {
  display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem;
  padding-top: 1.2rem; border-top: 1px solid var(--border); font-family: var(--sans); font-size: 0.92rem;
}
.pager a[rel="next"] { text-align: right; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-family: var(--sans); font-size: 0.9rem; padding: 1.5rem 0; }
.site-footer p { margin: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 0.6rem; align-items: baseline; }
.site-footer .copyright { margin-left: auto; }

@media (max-width: 40rem) {
  body { font-size: 1rem; }
  .bar { justify-content: flex-start; }
  .menu details ul { left: 0; right: auto; }
  main.wrap { padding-top: 1.5rem; }
  .home p:has(> img:only-child) { float: none; width: 70%; margin: 0 auto 1.2rem; }
}

@media print {
  .site-header, .site-footer, .pager, .anchor { display: none; }
  body { background: #fff; color: #000; }
}
