/*
 * masothue — one stylesheet, no build step, no web font.
 *
 * The system face on purpose: it ships optical sizing and Vietnamese diacritics on every
 * platform, and a tax lookup page has no business making a visitor download a typeface
 * before they can read a form. Tracking and leading change with size (tight on the display
 * line, neutral on body); colours are tokens, redefined for dark mode.
 */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0066cc;
  --accent-press: #0058b0;
  --accent-text: #ffffff;
  --danger: #c4161c;
  --chrome: rgba(245, 245, 247, 0.72);
  --scrim: rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.06);
  --focus: 0 0 0 4px rgba(0, 102, 204, 0.28);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989d;
    --line: rgba(255, 255, 255, 0.12);
    --accent: #2997ff;
    --accent-press: #1a7fe0;
    --accent-text: #ffffff;
    --danger: #ff6961;
    --chrome: rgba(22, 22, 23, 0.72);
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, 0.7);
    --focus: 0 0 0 4px rgba(41, 151, 255, 0.38);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 100%/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ the bar */

/* A translucent layer the page scrolls under, rather than an opaque strip. */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: var(--chrome);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}

.bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 980px;
  height: 52px;
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__mark svg rect {
  fill: var(--accent);
}

.brand__mark svg path {
  fill: none;
  stroke: var(--accent-text);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.location-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--muted);
  transition: transform 160ms var(--ease-out);
}

.location-chip:active {
  transform: scale(0.97);
}

.location-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.5;
  transition: background-color 200ms ease, opacity 200ms ease;
}

.location-chip[data-state="shared"] .location-chip__dot {
  background: #30d158;
  opacity: 1;
}

.location-chip[data-state="refused"] .location-chip__dot,
.location-chip[data-state="failed"] .location-chip__dot {
  background: var(--muted);
  opacity: 1;
}

/* ----------------------------------------------------------------- the hero */

.hero {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(56px, 14vh, 140px) max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left));
  text-align: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0;
}

/* Large type wants negative tracking and tight leading; the body below wants neither. */
.display {
  margin: 0;
  font-size: clamp(2.25rem, 7vw, 4rem);
  line-height: 1.06;
  letter-spacing: -0.025em;
  font-weight: 700;
  text-wrap: balance;
}

.lede {
  margin: 20px auto 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: clamp(1.0625rem, 2.2vw, 1.25rem);
  line-height: 1.45;
  letter-spacing: -0.005em;
  text-wrap: pretty;
}

/* ----------------------------------------------------------------- the search */

.search {
  margin: 40px auto 0;
  max-width: 600px;
  text-align: left;
}

.search__field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 48px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px -12px rgba(0, 0, 0, 0.12);
  transition: box-shadow 200ms ease, border-color 200ms ease;
}

.search__field:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.search[data-invalid] .search__field {
  border-color: var(--danger);
}

.search__icon {
  position: absolute;
  left: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

/* 16px or larger, or iOS zooms the page on focus. */
.search input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 0;
  background: transparent;
  font-size: 1.0625rem;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.search input:focus {
  outline: none;
  box-shadow: none;
}

.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search__hint,
.search__error {
  margin: 10px 4px 0;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.search__hint {
  color: var(--muted);
}

.search__error {
  color: var(--danger);
}

/* -------------------------------------------------------------- the buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: transform 160ms var(--ease-out), background-color 200ms ease;
}

/* Feedback on the press, not on the release. */
.button:active {
  transform: scale(0.97);
}

.button--primary {
  background: var(--accent);
  color: var(--accent-text);
}

.button--primary:active {
  background: var(--accent-press);
}

.button--secondary {
  background: transparent;
  color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .button--primary:hover {
    background: var(--accent-press);
  }

  .button--secondary:hover {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
  }

  .example:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  }
}

/* ------------------------------------------------------------- the examples */

.examples {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 28px auto 0;
  padding: 0;
  list-style: none;
}

.example {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875rem;
  transition: transform 160ms var(--ease-out), border-color 200ms ease;
}

.example:active {
  transform: scale(0.97);
}

.example span {
  color: var(--muted);
}

.example code {
  font: 500 0.875rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ the foot */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
}

.foot p {
  margin: 0;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ----------------------------------------------------------------- the sheet */

/*
 * The location explainer. A modal task, so it dims the page behind it. Centred on a wide
 * screen; a bottom sheet on a phone, rising from the edge it returns to. CSS transitions
 * rather than keyframes, so a close that interrupts the opening reverses from where it is.
 */
.sheet {
  width: min(420px, calc(100% - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  opacity: 1;
  transform: none;
  transition:
    opacity 240ms var(--ease-out),
    transform 240ms var(--ease-out),
    overlay 240ms allow-discrete,
    display 240ms allow-discrete;
}

.sheet:not([open]) {
  opacity: 0;
  transform: scale(0.96);
}

@starting-style {
  .sheet[open] {
    opacity: 0;
    transform: scale(0.96);
  }
}

.sheet::backdrop {
  background: var(--scrim);
  opacity: 1;
  transition: opacity 240ms ease, overlay 240ms allow-discrete, display 240ms allow-discrete;
}

.sheet:not([open])::backdrop {
  opacity: 0;
}

@starting-style {
  .sheet[open]::backdrop {
    opacity: 0;
  }
}

.sheet__inner {
  display: flex;
  flex-direction: column;
  padding: 28px 24px 20px;
}

.sheet__glyph {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.sheet__glyph svg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.sheet__title {
  margin: 0;
  font-size: 1.375rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 700;
  text-wrap: balance;
}

.sheet__body {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.sheet__body p {
  margin: 0;
  text-wrap: pretty;
}

.sheet__facts {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.sheet__facts li {
  position: relative;
  padding-left: 20px;
}

.sheet__facts li + li {
  margin-top: 6px;
}

.sheet__facts li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/*
 * Two answers of equal standing. "No" is not a grey afterthought under the fold: it is a
 * full-width button right beside "yes", because declining has to be as easy as agreeing.
 */
.sheet__actions {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.sheet__actions .button {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
}

@media (max-width: 559px) {
  .sheet {
    width: 100%;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    transition-timing-function: var(--ease-drawer);
    transition-duration: 380ms;
  }

  .sheet:not([open]) {
    opacity: 1;
    transform: translateY(100%);
  }

  @starting-style {
    .sheet[open] {
      opacity: 1;
      transform: translateY(100%);
    }
  }

  .sheet__inner {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

/* ----------------------------------------------------------------- the toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.875rem;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  transform: translateX(-50%);
  opacity: 1;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}

.toast[data-leaving] {
  opacity: 0;
  transform: translate(-50%, 8px);
}

@starting-style {
  .toast {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* --------------------------------------------------------- accessibility */

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .sheet:not([open]),
  .toast,
  .toast[data-leaving] {
    transform: none !important;
  }

  .sheet:not([open]) {
    opacity: 0;
  }

  @starting-style {
    .sheet[open] {
      opacity: 0;
      transform: none;
    }
  }
}

@media (prefers-reduced-transparency: reduce) {
  .bar {
    background: var(--bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: rgba(0, 0, 0, 0.4);
  }

  .button--secondary {
    box-shadow: inset 0 0 0 1px var(--accent);
  }
}
