/* Google Sans (wordmark) — self-hosted */
@font-face {
  font-family: "Google Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url("fonts/google-sans-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Instrument Sans (UI) — self-hosted */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("fonts/instrument-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("fonts/instrument-sans-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url("fonts/instrument-sans-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Keep color-scheme stable across themes — flipping to `dark` alone
     changes scrollbar metrics and shrinks vw-based button chrome. */
  color-scheme: dark light;
  --bg: #0a0a0a;
  --fg: #f2f2f0;
  --fg-muted: rgba(242, 242, 240, 0.78);
  --dot: #f2f2f0;
  --dot-hot: #9ec8ff;
  --btn-bg: transparent;
  --btn-border: rgba(242, 242, 240, 0.35);
  --btn-hover-bg: rgba(242, 242, 240, 0.08);
  --focus: #9ec8ff;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --title-max: 112.5rem;
  --title-width: min(calc(100vw - (var(--page-pad) * 2)), var(--title-max));
  --title-bottom: 38vh;
  --page-pad: max(20px, 4vw);
  --btn-h: 3.5rem;
  --btn-gap: 0.65rem;
  --btn-font: clamp(0.95rem, 3.6vw, 1.1rem);
  --btn-pad-x: clamp(0.75rem, 3vw, 1.25rem);
  --stack-gap: 22px;
  --content-top: 50vh;
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    --bg: #f4f4f2;
    --fg: #111111;
    --fg-muted: rgba(17, 17, 17, 0.75);
    --dot: #111111;
    --dot-hot: #1a4a8a;
    --btn-border: rgba(17, 17, 17, 0.3);
    --btn-hover-bg: rgba(17, 17, 17, 0.06);
    --focus: #1a4a8a;
  }
}

html[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #f2f2f0;
  --fg-muted: rgba(242, 242, 240, 0.78);
  --dot: #f2f2f0;
  --dot-hot: #9ec8ff;
  --btn-border: rgba(242, 242, 240, 0.35);
  --btn-hover-bg: rgba(242, 242, 240, 0.08);
  --focus: #9ec8ff;
}

html[data-theme="light"] {
  --bg: #f4f4f2;
  --fg: #111111;
  --fg-muted: rgba(17, 17, 17, 0.75);
  --dot: #111111;
  --dot-hot: #1a4a8a;
  --btn-border: rgba(17, 17, 17, 0.3);
  --btn-hover-bg: rgba(17, 17, 17, 0.06);
  --focus: #1a4a8a;
}

html[data-theme="sepia"] {
  --bg: #ebdab8;
  --fg: #5c4033;
  --fg-muted: rgba(92, 64, 51, 0.78);
  --dot: #5c4033;
  --dot-hot: #a67c52;
  --btn-border: rgba(92, 64, 51, 0.35);
  --btn-hover-bg: rgba(92, 64, 51, 0.08);
  --focus: #8b6914;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg);
  color: var(--fg);
  font-family: "Instrument Sans", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  scrollbar-gutter: stable;
}

/* Paper grain sits above the canvas (same z) but below UI */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px 180px;
  mix-blend-mode: multiply;
}

html[data-theme="sepia"] body::after {
  /* Fine grit + coarser fiber, warm-tinted — readable paper without muddying type */
  opacity: 0.56;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='f' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.15' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.42 0 0 0 0 0.30 0 0 0 0 0.16 0 0 0 0.72 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='280' height='280'%3E%3Cfilter id='c' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.42' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.38 0 0 0 0 0.26 0 0 0 0 0.12 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23c)'/%3E%3C/svg%3E");
  background-size: 140px 140px, 280px 280px;
  mix-blend-mode: multiply;
}

#field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
}

.wordmark-select {
  position: fixed;
  left: 50%;
  top: 0;
  z-index: 2;
  transform: translateX(-50%);
  margin: 0;
  padding: 0;
  max-width: calc(100% - (var(--page-pad) * 2));
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
  user-select: text;
  -webkit-user-select: text;
  cursor: default;
  pointer-events: none;
  touch-action: none;
}

.wordmark-select.is-active {
  pointer-events: auto;
}

.wordmark-select.is-dragging {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing;
}

.wordmark-select-text {
  margin: 0;
  padding: 0;
  font-family: "Google Sans", "Google Sans Variable", "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: var(--wordmark-size, 3rem);
  line-height: 1.15;
  letter-spacing: normal;
  text-align: center;
  white-space: nowrap;
  cursor: default;
}

.wordmark-select-text.is-stacked {
  white-space: normal;
}

.wordmark-select-text::selection {
  color: var(--fg);
  -webkit-text-fill-color: var(--fg);
  background: color-mix(in srgb, var(--focus) 35%, transparent);
}

.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 0 max(0.85rem, env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.content {
  width: var(--title-width);
  max-width: 100%;
  text-align: center;
  opacity: 0;
  transform: translateY(0.6rem);
  transition: opacity 0.65s var(--ease), transform 0.65s var(--ease);
  pointer-events: none;
  /* Same gap below title as between description and buttons */
  margin-top: var(--content-top);
  margin-bottom: 0.85rem;
  flex-shrink: 0;
}

.content[data-revealed="true"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.blurb {
  margin: 0 auto var(--stack-gap);
  width: 100%;
  font-size: clamp(0.95rem, 3.2vw, 1.25rem);
  line-height: 1.4;
  color: var(--fg-muted);
  text-align: center;
}

.blurb-desktop {
  display: none;
}

.blurb-mobile {
  display: block;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: var(--btn-gap);
  margin-bottom: 0;
  width: 100%;
}

.btn-row,
.icon-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: stretch;
  gap: var(--btn-gap);
  width: 100%;
}

.site-footer {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.65em 1.1em;
  margin: auto 0 0;
  width: var(--title-width);
  max-width: 100%;
  font-size: var(--company-font, clamp(0.85rem, 2.8vw, 1.05rem));
  letter-spacing: 0.03em;
  color: var(--fg-muted);
  white-space: nowrap;
  text-align: center;
  opacity: 0;
  transform: translateY(0.4rem);
  transition: opacity 0.65s var(--ease), transform 0.65s var(--ease);
  pointer-events: auto;
  z-index: 1;
}

.content[data-revealed="true"] ~ .site-footer {
  opacity: 1;
  transform: translateY(0);
}

.company-number {
  margin: 0;
  font-size: inherit;
  letter-spacing: inherit;
  color: inherit;
  white-space: nowrap;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.theme-toggle {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  color: inherit;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.theme-toggle-value {
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: from-font;
}

.theme-toggle:hover .theme-toggle-value {
  text-decoration-thickness: 2px;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: var(--btn-h);
  min-height: var(--btn-h);
  flex: 1 1 0;
  min-width: 0;
  padding: 0 var(--btn-pad-x);
  border: 1px solid var(--btn-border);
  border-radius: 0.45rem;
  background: var(--btn-bg);
  color: var(--fg);
  font: inherit;
  font-size: var(--btn-font);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease),
    transform 0.25s var(--ease);
}

.btn:hover {
  background: var(--btn-hover-bg);
  border-color: var(--fg);
}

.btn:active {
  transform: translateY(1px);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  aspect-ratio: 1 / 1;
  height: auto;
  min-height: var(--btn-h);
  border: 1px solid var(--btn-border);
  border-radius: 0.45rem;
  color: var(--fg);
  text-decoration: none;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease),
    transform 0.25s var(--ease);
}

.icon-btn svg {
  width: 52%;
  height: 52%;
  max-width: 2.75rem;
  max-height: 2.75rem;
}

@media (max-width: 899px) {
  .icon-btn svg {
    max-width: none;
    max-height: none;
  }
}

.icon-btn:hover {
  background: var(--btn-hover-bg);
  border-color: var(--fg);
}

.icon-btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Desktop: one line name (canvas), one line blurb, one line buttons; company number at foot */
@media (min-width: 900px) {
  :root {
    --btn-h: clamp(2.6rem, 3.8vw, 3.75rem);
    --btn-gap: clamp(0.55rem, 1.1vw, 1rem);
    --btn-font: clamp(0.9rem, 1.35vw, 1.25rem);
    --btn-pad-x: clamp(1rem, 1.8vw, 1.75rem);
    --stack-gap: 22px;
  }

  .stage {
    justify-content: flex-start;
    padding: var(--content-top) 0 max(1rem, env(safe-area-inset-bottom, 0px));
  }

  .content {
    margin-top: 0;
    margin-bottom: 0;
  }

  .blurb {
    font-size: clamp(0.7rem, 1.35vw, 1.2rem);
    text-align: center;
    margin-bottom: var(--stack-gap);
  }

  .blurb-desktop {
    display: inline;
    white-space: nowrap;
  }

  .blurb-mobile {
    display: none;
  }

  .actions {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    width: auto;
    max-width: 100%;
  }

  .btn-row {
    width: auto;
    flex: 0 1 auto;
  }

  .btn {
    flex: 0 1 auto;
    min-width: 9rem;
    border-radius: 0.35rem;
  }

  .icon-row {
    width: auto;
    flex: 0 0 auto;
  }

  .icon-btn {
    flex: 0 0 var(--btn-h);
    width: var(--btn-h);
    height: var(--btn-h);
    min-height: var(--btn-h);
    aspect-ratio: auto;
    border-radius: 0.35rem;
  }

  .icon-btn svg {
    width: 48%;
    height: 48%;
    max-width: 1.5rem;
    max-height: 1.5rem;
  }

  .site-footer {
    margin-top: auto;
    margin-bottom: 0;
    padding-top: 1rem;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .content,
  .site-footer {
    transition: none;
  }
}

/* Emergency phone landscape only (toggled by JS: mobile + short height) */
html.is-short-viewport .stage {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  padding-bottom: max(0.4rem, env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}

html.is-short-viewport .content {
  position: fixed;
  left: var(--content-left);
  top: 50%;
  width: var(--content-width);
  max-width: none;
  margin: 0;
  text-align: left;
  transform: translateY(calc(-50% + 0.6rem));
  z-index: 1;
}

html.is-short-viewport .content[data-revealed="true"] {
  transform: translateY(-50%);
}

html.is-short-viewport .blurb {
  margin: 0 0 var(--stack-gap);
  text-align: left;
}

html.is-short-viewport .blurb-mobile {
  display: none;
}

html.is-short-viewport .blurb-desktop {
  display: block;
  white-space: normal;
}

html.is-short-viewport .actions {
  align-items: stretch;
  width: 100%;
}

html.is-short-viewport .icon-btn {
  aspect-ratio: auto;
  height: var(--btn-h);
  min-height: var(--btn-h);
  max-height: var(--btn-h);
}

html.is-short-viewport .icon-btn svg {
  width: 48%;
  height: 48%;
  max-width: 1.25rem;
  max-height: 1.25rem;
}

html.is-short-viewport .site-footer {
  position: fixed;
  left: var(--content-left);
  bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
  width: var(--content-width);
  max-width: none;
  margin: 0;
  padding: 0;
  justify-content: center;
  white-space: nowrap;
  z-index: 1;
}

html.is-short-viewport .wordmark-select {
  left: auto;
  transform: none;
  max-width: none;
}

html.is-short-viewport .wordmark-select-text {
  text-align: right;
}
