/* daltonjallen.com
   Spreadsheet chrome, pure CSS, no JavaScript: a formula bar, a column header,
   a row-number gutter, a selected cell (A1), and sticky sheet tabs. */

:root {
  --bg: #fcfcfa;
  --fg: #1f2328;
  --muted: #6e747d;
  --rule: #d9dde3;
  --chrome: #f3f4f6;
  --chrome-active: #e4e7eb;
  --accent: #1a7f37;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --gutter: 3rem;
  /* Column A width, in rem so the header strip and the content agree on it. */
  --measure: 38.5rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111417;
    --fg: #e6e8eb;
    --muted: #8b929b;
    --rule: #2a3038;
    --chrome: #171b20;
    --chrome-active: #20262d;
    --accent: #3fb950;
  }
}

/* Base ------------------------------------------------------------------ */

html { box-sizing: border-box; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover { text-decoration-thickness: 2px; }

/* Selected-cell outline on keyboard focus. */
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 1px;
}

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
h1.title { font-size: 2rem; margin: 0 0 1.75rem; }
h2 { font-size: 1.375rem; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1.125rem; margin: 2rem 0 0.5rem; }
p { margin: 0 0 1.1rem; }
ul, ol { margin: 0 0 1.1rem; padding-left: 1.5rem; }
code, pre { font-family: var(--font-mono); font-size: 0.9em; }

/* Selected cell: the title is A1 and gets the border the formula bar refers
   to, plus the fill handle in the corner. A headline jumped to from the sheet
   tabs (e.g. #contact) becomes the selected cell too. */
h1.title,
main#content h2:target {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  margin-left: -0.45rem;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
}
h1.title::after,
main#content h2:target::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border: 1px solid var(--bg);
}
main#content h2:target { scroll-margin-top: 1.5rem; }

/* Headshot: a standalone image paragraph exports as <figure><img class="headshot">.
   Floated beside the opening paragraphs; not counted as a row. */
figure { margin: 0; }
figure:has(> img.headshot) {
  float: right;
  width: 8.5rem;
  margin: 0.25rem 0 1rem 1.5rem;
}
img.headshot {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
  border: 1px solid var(--rule);
}

/* Definition lists (used for Contact) as a two-column range. */
dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1.5rem;
  row-gap: 0.4rem;
  margin: 0 0 1.1rem;
}
dt {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  align-self: baseline;
  padding-top: 0.2em;
}
dd { margin: 0; }

/* Formula bar (site header) -------------------------------------------- */

#preamble .formula-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.4rem 0.4rem;
  border-bottom: 1px solid var(--rule);
  background: var(--chrome);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.4;
}
/* Name box and formula field read as inputs. */
#preamble .cell-ref,
#preamble .formula {
  padding: 0.2rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 2px;
}
#preamble .cell-ref {
  min-width: calc(var(--gutter) + 0.5rem);
  text-align: center;
}
#preamble .fx {
  font-style: italic;
  color: var(--muted);
  padding: 0 0.15rem;
}
#preamble .formula {
  flex: 1;
  color: var(--fg);
  text-decoration: none;
}
#preamble .formula:hover { text-decoration: underline; }

/* Column header: a corner cell above the gutter, then column A, which is
   highlighted because A1 is the selected cell. */
#preamble .col-head {
  display: flex;
  background: var(--chrome);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5rem;
  color: var(--muted);
}
#preamble .corner {
  flex: none;
  width: var(--gutter);
  border-right: 1px solid var(--rule);
}
#preamble .col {
  flex: none;
  width: calc(var(--measure) + 2rem);
  text-align: center;
  border-right: 1px solid var(--rule);
}
#preamble .col.is-active {
  color: var(--accent);
  font-weight: 600;
  background: var(--chrome-active);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* Content column with row-number gutter --------------------------------- */

/* The sheet is anchored to the left edge like a real spreadsheet: the gutter
   runs down the viewport's left side and column A starts beside it. The
   content column is width-limited for readability but never centered. */
main#content {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: calc(var(--measure) + var(--gutter) + 2rem);
  margin: 0;
  padding: 2.5rem 1rem 3.5rem calc(var(--gutter) + 1rem);
  counter-reset: row;
}

/* The gutter strip itself. */
main#content::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--gutter);
  background: var(--chrome);
  border-right: 1px solid var(--rule);
}

/* Each top-level block is a row. Lists count once; contact entries count per label. */
main#content > header > h1.title,
main#content > p,
main#content > ul,
main#content > ol,
main#content > blockquote,
main#content > pre,
main#content > table,
main#content > section > h2,
main#content > section > h3,
main#content > section > .outline-text-2 > :not(dl),
main#content dl > dt {
  position: relative;
  counter-increment: row;
}

main#content > header > h1.title::before,
main#content > p::before,
main#content > ul::before,
main#content > ol::before,
main#content > blockquote::before,
main#content > pre::before,
main#content > table::before,
main#content > section > h2::before,
main#content > section > h3::before,
main#content > section > .outline-text-2 > :not(dl)::before,
main#content dl > dt::before {
  content: counter(row);
  position: absolute;
  top: 0;
  left: calc(-1 * (var(--gutter) + 1rem));
  width: var(--gutter);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.7rem;
  color: var(--muted);
  pointer-events: none;
  user-select: none;
}
main#content dl > dt::before { line-height: 1.7rem; }

/* The selected cell's row header is highlighted, like its column header. */
main#content > header > h1.title::before,
main#content > section > h2:target::before {
  left: calc(-1 * (var(--gutter) + 1rem - 0.45rem));
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 600;
  background: var(--chrome-active);
  box-shadow: inset -2px 0 0 var(--accent);
}

/* Sheet tabs (site footer) --------------------------------------------- */

/* The tab strip stays pinned to the bottom of the window, as in a workbook. */
#postamble {
  position: sticky;
  bottom: 0;
  z-index: 1;
}
#postamble .sheet-tabs {
  display: flex;
  align-items: stretch;
  padding: 0 1rem;
  border-top: 1px solid var(--rule);
  background: var(--chrome);
  font-size: 0.875rem;
  line-height: 1.4;
  overflow-x: auto;
}
#postamble .tab {
  padding: 0.45rem 1.1rem;
  margin-top: -1px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-top-color: var(--rule);
  white-space: nowrap;
}
#postamble .tab:hover { color: var(--fg); background: var(--chrome-active); }
#postamble .tab.is-active {
  color: var(--accent);
  background: var(--bg);
  border-color: var(--rule);
  border-top-color: var(--bg);
  border-bottom: 2px solid var(--accent);
  font-weight: 600;
}
#postamble .tab-new {
  color: var(--muted);
  font-weight: 600;
  padding-inline: 0.8rem;
}
#postamble .tab-new:hover { background: none; color: var(--muted); }

/* Narrow screens: drop the gutter and column header, keep everything else */

@media (max-width: 40rem) {
  main#content { padding-left: 1rem; }
  main#content::before { display: none; }
  #preamble .col-head { display: none; }
  main#content > header > h1.title::before,
  main#content > p::before,
  main#content > ul::before,
  main#content > ol::before,
  main#content > blockquote::before,
  main#content > pre::before,
  main#content > table::before,
  main#content > section > h2::before,
  main#content > section > h3::before,
  main#content > section > .outline-text-2 > :not(dl)::before,
  main#content dl > dt::before { display: none; }
  figure:has(> img.headshot) { width: 6rem; margin-left: 1rem; }
  dl { grid-template-columns: 1fr; row-gap: 0.15rem; }
  dd { margin-bottom: 0.6rem; }
}
