/* hanrahan.cloud
   Plain single-column page by default. html.tour (set by the inline probe in
   index.html) layers the 3D scene underneath and turns each section into a stop. */

:root {
  --bg: #ffffff;
  --text: #171717;
  --muted: #6b6b6b;
  --border: #e2e2e2;
  --border-strong: #8f8f8f;        /* input borders: 3:1 on white */
  --accent: #2c5fbf;
  --accent-dark: #1f4690;
  --error: #b42318;
  --success: #1f7a3a;
  --stage: #e9e9e7;                /* the 3D backdrop; tour.js reads it */
  --underline: rgba(44, 95, 191, 0.35);
  --on-text: #ffffff;              /* text on a --text fill (the Send button) */
  --text-strong: #000000;
  --header-h: 3rem;
  --radius: 6px;
}

/* Dark, only when the reader picks it (theme.js; the head probe restores it
   before first paint). The system setting is deliberately ignored. */
:root[data-theme="dark"] {
  color-scheme: dark;              /* beats the "light" meta tag */
  --bg: #161718;
  --text: #ececea;
  --muted: #9a9a9a;
  --border: #2e3033;
  --border-strong: #6e7074;
  --accent: #86a8f0;
  --accent-dark: #a9c2f6;
  --error: #f28b82;
  --success: #6fcf8e;
  --stage: #202123;
  --underline: rgba(134, 168, 240, 0.4);
  --on-text: #161718;
  --text-strong: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 106.25%;              /* 17px at the default size, and follows the reader's setting */
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--underline);
  text-underline-offset: 0.15em;
  transition: color 0.15s, text-decoration-color 0.15s;
}

a:hover {
  color: var(--accent-dark);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stop:focus {
  outline: none;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
  font-weight: 600;
}

h1 {
  font-size: 1.75rem;
}

main > h1 {                        /* a plain page's title (privacy.html) */
  margin-bottom: 0.75rem;
}

h2 {
  font-size: 1.125rem;
  margin: 3.5rem 0 1rem;
}

p {
  margin: 0 0 1rem;
}

.sr-only,
html:not(.tour) #h-intro {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: -10000px;
  top: 0.5rem;
  z-index: 3;
  padding: 0.4rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.skip:focus {
  left: 1rem;
}

/* Plain layout */

.site-header,
main,
.site-footer {
  max-width: 42rem;
  margin: 0 auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem 1.5rem;
  padding-top: 3rem;
  margin-bottom: 3rem;
}

.site-header .name {
  color: var(--text);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a,
.toc-menu a {
  color: var(--muted);
  text-decoration: none;
}

.toc a:hover,
.toc-menu a:hover,
.toc a[aria-current] {
  color: var(--text);
}

.toc-menu,
.stage,
.part,
.next,
.tour-hint,
.savedata-offer,
.only-tour,
.only-optout {
  display: none;
}

html.can-tour .savedata-offer {
  display: block;
}

html.optout .only-optout {
  display: inline;
}

.lead {
  font-size: 1.125rem;
}

.fallback-note {
  color: var(--muted);
}

.text-button {
  padding: 0;
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  text-decoration: underline;
  text-decoration-color: var(--underline);
  text-underline-offset: 0.15em;
  cursor: pointer;
}

.text-button:hover {
  color: var(--accent-dark);
  background: none;
  text-decoration-color: currentColor;
}

/* Work list */

.work {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  border-top: 1px solid var(--border);
}

.work li {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.work-name {
  font-weight: 600;
}

.work-desc {
  display: block;
  color: var(--muted);
}

/* Form */

.no-js .contact-form,
.no-js .js-only {
  display: none;
}

.field {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

.field-meta {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: var(--muted);
  text-align: right;
}

.char-counter.is-limit {
  color: var(--error);
}

.honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

button {
  padding: 0.65rem 1.1rem;
  font: inherit;
  font-weight: 500;
  color: var(--on-text);
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: var(--radius);
  cursor: pointer;
}

button:hover {
  background: var(--text-strong);
  border-color: var(--text-strong);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.form-status {
  min-height: 1.6em;
  margin: 1rem 0 0.5rem;
  color: var(--muted);
}

.form-status.is-error {
  color: var(--error);
}

.form-status.is-success {
  color: var(--success);
}

.form-note {
  font-size: 0.875rem;
  color: var(--muted);
}

/* Dark mode switch: fixed in the bottom-right corner in every layout. */

.theme-toggle {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
}

.theme-toggle .sun,
[data-theme="dark"] .theme-toggle .moon,
.no-js .theme-toggle {
  display: none;
}

[data-theme="dark"] .theme-toggle .sun {
  display: block;
}

@media print, (forced-colors: active) {
  .theme-toggle {
    display: none;
  }
}

/* Footer */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  padding-bottom: 4rem;
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}

/* Tour: the scene sits in a fixed layer behind the page and every section
   becomes a stop with one white panel. Screen only, so print stays plain. */

@media screen {
  html.tour {
    background: var(--stage);
    scroll-padding-top: var(--header-h);
    overflow-x: clip;
  }

  html.tour body {
    background: transparent;
  }

  html.tour .site-header {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-wrap: nowrap;
    align-items: center;
    max-width: none;
    height: var(--header-h);
    margin: 0;
    padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
    white-space: nowrap;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

  html.tour .site-header .name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1rem;
  }

  html.tour .site-header nav {
    flex: none;
  }

  html.tour .toc {
    display: none;
  }

  html.tour .toc-menu {
    display: block;
    position: relative;
  }

  .toc-menu summary {
    color: var(--muted);
    cursor: pointer;
    list-style: none;
  }

  .toc-menu summary::-webkit-details-marker {
    display: none;
  }

  .toc-menu summary:hover,
  .toc-menu[open] summary {
    color: var(--text);
  }

  .toc-menu ol {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    min-width: 11rem;
    max-height: calc(100svh - var(--header-h) - 1rem);
    overflow-y: auto;
    margin: 0;
    padding: 0.4rem 0;
    list-style: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .toc-menu li a {
    display: block;
    padding: 0.35rem 1rem;
  }

  .toc-menu a[aria-current] {
    color: var(--text);
  }

  html.tour .stage {
    display: block;
    position: fixed;
    inset: 0 0 auto 0;
    height: 100vh;
    height: 100lvh;
    z-index: 0;
    pointer-events: none;
    background: var(--stage);
  }

  html.tour .stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.6s;
  }

  html.tour-ready .stage canvas {
    opacity: 1;
  }

  html.tour-ready .stage canvas.dip {
    opacity: 0;
    transition-duration: 0.08s;
  }

  html.tour main {
    --gap: 0;
    position: relative;
    z-index: 1;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  html.tour .stop {
    padding: 50svh max(0.75rem, env(safe-area-inset-right)) calc(var(--gap, 0) * 85svh) max(0.75rem, env(safe-area-inset-left));
  }

  html.tour .stop:last-child {
    min-height: 100svh;
  }

  html.tour .panel {
    padding: 1.25rem;
    overflow-wrap: anywhere;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  html.tour .panel h2 {
    margin-top: 0;
  }

  html.tour #h-intro {
    margin-bottom: 0.75rem;
  }

  html.tour .tour-hint {
    display: block;
    color: var(--muted);
  }

  html.tour .part {
    display: block;
    margin: 1.25rem 0 0;
    padding-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
  }

  html.tour .next {
    display: block;
    margin: 0.4rem 0 0;
    font-size: 0.9375rem;
  }

  html.tour .only-tour {
    display: inline;
  }

  html.tour .site-footer {
    position: relative;
    z-index: 1;
    max-width: none;
    margin: 0;
    padding: 1.5rem max(1rem, env(safe-area-inset-right)) calc(4.5rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    background: var(--bg);
  }
}

/* Wide screens: the panel is a left column and the part is framed to its right. */

@media screen and (min-width: 720px) and (min-aspect-ratio: 5/4) {
  html.tour {
    --layout: side;
  }

  html.tour .stop {
    padding: 2rem 0 calc(var(--gap, 0) * 100svh);
  }

  html.tour .panel {
    width: min(26rem, 40vw);
    margin-left: max(clamp(1.5rem, 5vw, 4.5rem), calc(env(safe-area-inset-left) + 0.75rem));
    padding: 1.5rem 1.75rem;
  }

  /* The pinned panel's travel has to be inside .hold's content box: a sticky
     box can't move into its parent's padding. */
  html.tour .stop.fit .hold::after {
    content: "";
    display: block;
    height: 45svh;
  }

  html.tour .stop.fit .panel {
    position: sticky;
    top: calc(var(--header-h) + 2rem);
  }

  html.tour #intro .hold {
    display: flex;
    align-items: center;
    min-height: calc(100svh - var(--header-h) - 4rem);
  }
}

@media screen and (min-width: 54em) {
  html.tour .toc {
    display: flex;
  }

  html.tour .toc-menu {
    display: none;
  }
}

@media print {
  #h-intro {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  a,
  input,
  textarea,
  html.tour .stage canvas {
    transition: none;
  }
}
