/* Open Sans, self-hosted (SIL OFL 1.1): the CSP allows no third-party font hosts. */
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url("/fonts/open-sans-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url("/fonts/open-sans-latin.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;
}

/* Tokens: the v2 "jajco" yolk scale on cool grays. Every pair used for text meets WCAG AA (4.5:1)
   in both themes; check new ones before adding them. */
:root {
  --jajco-50: #fffee7;
  --jajco-100: #fffec1;
  --jajco-400: #ffdb0d;
  --jajco-500: #fcc011;
  --jajco-600: #d19500;
  --jajco-700: #a66a02;
  --jajco-900: #74430f;
  --jajco-950: #442304;

  --bg: #f9fafb;
  --surface: #fff;
  --text: #111827;
  --text-muted: #6b7280;
  --heading: #1f2937;
  --line: #d7d7d7;
  --accent: var(--jajco-500);
  /* Yellow for large text on the light background: 3.6:1, enough for large text under WCAG AA. */
  --accent-text: #b07a00;
  --on-accent: var(--jajco-950);
  /* A shade under jajco-700, which is 4.3:1 on --bg and too light for text. */
  --link: #935c02;
  --icon: var(--jajco-700);
  --icon-bg: var(--jajco-50);
  --scrollbar: #d1d5db;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.1), 0 1px 2px rgb(0 0 0 / 0.06);
  --focus: var(--link);
  --danger-bg: #fef2f2;
  --danger-text: #991b1b;
  --warn-bg: var(--jajco-50);
  --warn-line: var(--jajco-600);
  --warn-text: var(--jajco-950);
  --map-tiles: none;

  --font: "Open Sans", Lato, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: clamp(15px, 4vw, 60px);
  color-scheme: light dark;
}

/* The theme switch sets `data-theme` on <html>; without it the system setting decides. The dark
   tokens are listed twice because a media query cannot share a rule with a plain selector. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  --accent-text: var(--jajco-500);
  --bg: #14110b;
  --surface: #211c12;
  --text: #f3f0e6;
  --text-muted: #a8a290;
  --heading: #fbf7e4;
  --line: #3a3322;
  --link: var(--jajco-400);
  --icon: var(--jajco-500);
  --icon-bg: #33270a;
  --scrollbar: #4a412b;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.5), 0 1px 2px rgb(0 0 0 / 0.4);
  --focus: var(--jajco-400);
  --danger-bg: #3b1414;
  --danger-text: #fecaca;
  --warn-bg: #33270a;
  --warn-line: var(--jajco-600);
  --warn-text: var(--jajco-100);
  /* OpenStreetMap only has light tiles; inverting them keeps the hues and fits the dark page. */
  --map-tiles: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-text: var(--jajco-500);
    --bg: #14110b;
    --surface: #211c12;
    --text: #f3f0e6;
    --text-muted: #a8a290;
    --heading: #fbf7e4;
    --line: #3a3322;
    --link: var(--jajco-400);
    --icon: var(--jajco-500);
    --icon-bg: #33270a;
    --scrollbar: #4a412b;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.5), 0 1px 2px rgb(0 0 0 / 0.4);
    --focus: var(--jajco-400);
    --danger-bg: #3b1414;
    --danger-text: #fecaca;
    --warn-bg: #33270a;
    --warn-line: var(--jajco-600);
    --warn-text: var(--jajco-100);
    /* OpenStreetMap only has light tiles; inverting them keeps the hues and fits the dark page. */
    --map-tiles: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.5);
    color-scheme: dark;
  }
}

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

[hidden] {
  /* biome-ignore lint/complexity/noImportantStyles: the hidden attribute must beat component display rules */
  display: none !important;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  /* The visible viewport on phones, so a short page shows the footer without scrolling. */
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: var(--scrollbar);
}

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

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

/* First tab stop: hidden off-screen until it takes focus. */
.skip-link {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* The skip link moves focus here; a ring around the whole page body would be noise. */
#main:focus-visible {
  outline: none;
}

/* Top bar with the page settings, right-aligned above the content. */
.topbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  width: min(100% - 2 * var(--gutter), 70rem);
  margin-inline: auto;
  padding-top: 0.875rem;
}

.switch {
  margin: 0;
}

.switch__group {
  display: flex;
  gap: 0.125rem;
  margin: 0;
  padding: 0.1875rem;
  border: 0;
  border-radius: 9999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.switch__option {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  font: inherit;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition:
    color 0.15s ease,
    background-color 0.15s ease;
}

.switch__option:hover {
  color: var(--text);
}

.switch__option[aria-pressed="true"] {
  color: var(--on-accent);
  background: var(--accent);
}

.switch__option:focus-visible {
  outline-offset: 0;
}

.switch__option--text {
  width: auto;
  min-width: 2.25rem;
  padding-inline: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.switch__icon {
  width: 1.125rem;
  height: 1.125rem;
}

/* Layout: one centred column, as wide as the v2 eight-column grid. */
.page {
  width: min(100% - 2 * var(--gutter), 70rem);
  flex: 1 0 auto;
  margin-inline: auto;
  padding-bottom: 3rem;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-block: 2.5rem 0.75rem;
  text-align: center;
}

.hero__title {
  margin: 0 0 1.75rem;
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  color: var(--heading);
}

.hero__subtitle {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Inputs: the v2 pill. */
.input {
  width: 100%;
  /* One height for every input, the date picker included (its inner fields add their own padding). */
  block-size: 3.5rem;
  padding: 1rem 1.5rem;
  border: 0;
  border-radius: 9999px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input::placeholder {
  color: var(--text-muted);
}

.input::-webkit-datetime-edit {
  padding: 0;
}

.input::-webkit-date-and-time-value {
  text-align: start;
}

/* Autofill would paint the browser's own background and text colours over the theme. */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow:
    inset 0 0 0 100vmax var(--surface),
    var(--shadow);
  transition: background-color 600000s 0s;
}

/* Rings hug the control instead of the global 2px gap. */
.input:focus-visible,
.expiry__select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

.input[aria-invalid="true"] {
  outline: 2px solid var(--danger-text);
  outline-offset: 0;
}

.shorten,
.lookup {
  max-width: 48rem;
  margin: 2.5rem auto 1.25rem;
  padding: 0.25rem;
}

/* v2 form: the round right end of the input lies over the button, which is rounded on the right only. */
.pill {
  --pill-overlap: 2.5rem;
  display: flex;
  align-items: stretch;
}

.pill__input {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
}

.pill__submit {
  position: relative;
  flex: none;
  margin-inline-start: calc(-1 * var(--pill-overlap));
  padding: 0 1.75rem 0 calc(var(--pill-overlap) + 1.5rem);
  border: 0;
  border-start-end-radius: 9999px;
  border-end-end-radius: 9999px;
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

/* An inset ring follows the button's own corners and stays inside it. */
.pill__submit:focus-visible {
  outline: none;
  box-shadow:
    inset 0 0 0 3px var(--accent),
    inset 0 0 0 5px var(--on-accent),
    var(--shadow);
}

.pill__submit:hover {
  background: var(--jajco-400);
}

.pill__submit:hover:focus-visible {
  box-shadow:
    inset 0 0 0 3px var(--jajco-400),
    inset 0 0 0 5px var(--on-accent),
    var(--shadow);
}

.pill__submit:disabled {
  cursor: progress;
  opacity: 0.7;
}

.options {
  margin-top: 0.75rem;
}

.options__summary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.25rem;
  font-size: 0.875rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.options__summary::-webkit-details-marker {
  display: none;
}

.options__summary::before {
  content: "";
  border-block: 5px solid transparent;
  border-inline-start: 7px solid currentColor;
  transition: transform 0.15s ease;
}

.options[open] > .options__summary::before {
  transform: rotate(90deg);
}

.options__body {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* One control: the select fills the row and the label sits on its left end, so a click on the
   label opens the list and the focus ring goes round both. */
.expiry {
  --expiry-label: 7.5rem;
  position: relative;
  display: grid;
}

.expiry__label {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--expiry-label);
  border-start-start-radius: 9999px;
  border-end-start-radius: 9999px;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  pointer-events: none;
}

/* Own chevron, kept clear of the right end; the native one sits in the corner. */
.expiry::after {
  content: "";
  position: absolute;
  inset-inline-end: 1.5rem;
  top: 50%;
  width: 0.5rem;
  height: 0.5rem;
  border-inline-end: 2px solid var(--text);
  border-block-end: 2px solid var(--text);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.expiry__select {
  width: 100%;
  min-width: 0;
  block-size: 3.5rem;
  appearance: none;
  padding: 0 3rem 0 calc(var(--expiry-label) + 1rem);
  border: 0;
  border-radius: 9999px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.hint {
  margin: 0.375rem 1.5rem 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.error {
  margin: 0.75rem 0 0;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.9375rem;
  color: var(--danger-text);
  background: var(--danger-bg);
}

.lookup__title {
  margin: 0 0 1.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
  font-weight: 400;
  text-align: center;
  color: var(--text-muted);
}

.lookup__title > span {
  display: inline-block;
  padding-inline: 0.5rem;
  background: var(--bg);
  transform: translateY(50%);
}

/* Result card: the v2 info panel. */
.result {
  display: grid;
  gap: 1rem;
  max-width: 48rem;
  margin: 2.5rem auto 1.25rem;
  padding: 1.5rem;
  border-radius: 0.75rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result__title {
  margin: 0;
  font-size: 1.5rem;
  color: var(--heading);
}

.result__title:focus {
  outline: none;
}

.result p {
  margin: 0;
}

.result__link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  background: var(--bg);
}

.result__short {
  flex: 1 1 14rem;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  color: var(--link);
}

.result__short:hover {
  text-decoration: underline;
}

.result__share {
  display: flex;
  flex: 0 1 auto;
  gap: 0.5rem;
}

.result__copy {
  min-width: 7rem;
}

.result__again {
  align-self: center;
  margin-inline-start: 0.5rem;
  font-weight: 600;
}

.result__target,
.result__expiry {
  overflow-wrap: anywhere;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.field__label,
.notice__title {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.copy-row__value {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  overflow-wrap: anywhere;
  font-weight: 600;
  color: var(--link);
  background: var(--bg);
}

.copy-row__value--key {
  font-family: var(--mono);
  font-size: 0.9375rem;
  color: var(--text);
  user-select: all;
}

.notice {
  padding: 0.875rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.9375rem;
}

.notice p + p,
.notice p + .copy-row {
  margin-top: 0.5rem;
}

.notice--warning {
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
}

.notice--warning .copy-row__value {
  background: var(--surface);
}

/* The key once it is saved to History: still there to copy, no longer a warning. */
.notice--quiet {
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--line);
}

.notice--quiet .notice__title {
  color: var(--text);
}

.notice--quiet .copy-row__value {
  background: var(--surface);
}

.notice--idn {
  color: var(--danger-text);
  background: var(--danger-bg);
}

.result__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.button {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  border: 2px solid var(--accent);
  border-radius: 9999px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--on-accent);
  background: var(--accent);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

/* Border and fill change together, so the hover state has no ring of the old colour. */
.button:hover {
  border-color: var(--jajco-400);
  background: var(--jajco-400);
}

.button--ghost {
  color: var(--text);
  background: transparent;
}

.button--ghost:hover {
  color: var(--on-accent);
}

a {
  color: var(--link);
}

/* Footer: at the end of the page, so it never covers content. */
.footer {
  padding: 0.75rem 0.25rem 1rem;
  border-top: 1px solid var(--line);
}

.footer__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
  list-style: none;
}

.footer__item {
  position: relative;
}

.footer__item:not(:last-child)::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 1px;
  background: var(--line);
}

.footer__link {
  display: block;
  padding: 0.25rem 0.75rem 0.375rem;
  margin-block: 0.25rem;
  text-decoration: none;
  color: var(--text);
  transition: color 0.15s ease;
}

.footer__link:hover {
  color: var(--link);
}

/* Toasts: stacked at the bottom of the viewport, newest last. */
.toasts {
  position: fixed;
  inset: auto 0 1rem;
  z-index: 60;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0 var(--gutter);
  pointer-events: none;
}

.toasts__region {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  width: 100%;
}

.toasts__region:empty {
  display: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(100%, 28rem);
  padding: 0.75rem 0.5rem 0.75rem 1rem;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--toast-mark);
  border-radius: 0.75rem;
  color: var(--text);
  background: var(--surface);
  box-shadow:
    0 10px 25px -5px rgb(0 0 0 / 0.18),
    0 4px 10px -4px rgb(0 0 0 / 0.12);
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast--success {
  --toast-mark: var(--accent);
}

.toast--info {
  --toast-mark: var(--text-muted);
}

.toast--error {
  --toast-mark: var(--danger-text);
  border-color: color-mix(in srgb, var(--danger-text) 25%, transparent);
  border-inline-start-color: var(--toast-mark);
  color: var(--danger-text);
  background: var(--danger-bg);
}

.toast--leaving {
  opacity: 0;
  transform: translateY(0.5rem);
}

.toast__message {
  flex: 1;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.toast__close {
  display: grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.toast__close:hover {
  background: color-mix(in srgb, currentColor 12%, transparent);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
}

@media (max-width: 30rem) {
  .hero {
    padding-top: 1.5rem;
  }

  .hero__title {
    font-size: 2.5rem;
  }

  .hero__subtitle {
    font-size: 1.0625rem;
  }

  .pill {
    --pill-overlap: 1.75rem;
  }

  .pill__submit {
    padding-inline: calc(var(--pill-overlap) + 1rem) 1.25rem;
  }

  .copy-row {
    flex-wrap: wrap;
  }

  .result__short {
    font-size: 1.5rem;
  }

  .result__share,
  .result__share .button {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    /* biome-ignore lint/complexity/noImportantStyles: reduced motion must override every component transition */
    transition: none !important;
    /* biome-ignore lint/complexity/noImportantStyles: reduced motion must override every component scroll behavior */
    scroll-behavior: auto !important;
    /* biome-ignore lint/complexity/noImportantStyles: reduced motion must override every component animation */
    animation: none !important;
  }
}
