/* Shared tokens and layout for every page of the Bureau of Lost Pages post office.
   Strawberry ink on butter-yellow paper (the Cute world of the brief). Contrast checked:
   --ink on --paper 6.6:1, --pencil on --paper 10.9:1, --sky on --paper 5.2:1. */

:root {
  --paper: #fff3c4;
  --paper-deep: #fbe59a;
  --card: #fffbea;
  --ink: #b5122e;
  --ink-soft: #e8566a;
  --ink-wash: #fbd3d3;
  --pencil: #36323f;
  --pencil-soft: #5b5566;
  --sky: #1f5f9e;
  --leaf: #2f6e4f;
  --line: #e7cf7c;
  --shadow: 0 2px 0 #e2c768, 0 10px 24px rgb(120 80 0 / 0.12);
  --radius: 14px;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Devanagari', sans-serif;
  --font-hand: 'Patrick Hand', 'Comic Neue', 'Segoe Print', 'Bradley Hand', cursive;
  --font-mono: 'Courier Prime', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.723 12.9%, 0.938 16.7%, 1.017 20.3%, 1.042 24%, 1.034 28.4%, 0.998 39.4%, 0.993 47.2%, 1);
  color-scheme: light;
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font: 1rem/1.55 var(--font-body);
  color: var(--pencil);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgb(181 18 46 / 0.07) 1px, transparent 1.5px);
  background-size: 22px 22px;
}

a { color: var(--sky); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }

:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 50;
  padding: 0.6rem 1rem;
  background: var(--pencil);
  color: var(--card);
  border-radius: 8px;
  text-decoration: none;
}
.skip:focus { top: 0.75rem; }

.wrap { width: min(100% - 2rem, 68rem); margin-inline: auto; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Top bar: brand on the left, controls on the right. */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding-block: 0.9rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.brand svg { width: 1.6rem; height: 1.6rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.55rem 1.05rem;
  border: 2px solid var(--pencil);
  border-radius: 999px;
  background: var(--card);
  color: var(--pencil);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--pencil);
  transition: transform 0.12s var(--ease-out), box-shadow 0.12s var(--ease-out);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--pencil); color: var(--pencil); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--pencil); }
.btn--ink { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: 0 3px 0 #7c0c20; }
.btn--ink:hover { color: #fff; box-shadow: 0 4px 0 #7c0c20; }
.btn--ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; }
.btn--small { min-height: 36px; padding: 0.3rem 0.8rem; font-size: 0.9rem; }

/* Ways out: always visible, works without JS. */
.ways-out {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.ways-out form { display: flex; flex-wrap: wrap; gap: 0.4rem; flex: 1 1 16rem; min-width: 0; }
.ways-out input[type='search'] {
  flex: 1 1 8rem;
  min-width: 0;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--pencil);
  border-radius: 999px;
  background: var(--card);
  color: var(--pencil);
  font: inherit;
}

.page-footer {
  margin-top: 3rem;
  padding-block: 1.5rem 2.5rem;
  border-top: 2px dashed var(--line);
  color: var(--pencil-soft);
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .btn { border: 2px solid ButtonText; }
}

/* Top bar controls: a language rail with a sliding ink stamp, and two little lever switches. */
.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.langs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(2.9rem, 1fr));
  padding: 3px;
  border: 2px solid var(--pencil);
  border-radius: 999px;
  background: var(--card);
  box-shadow: inset 0 2px 0 rgb(54 50 63 / 0.08), 0 2px 0 var(--pencil);
  isolation: isolate;
}
/* The ink stamp slides under the language in use (--i is set by the page). */
.langs::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 3);
  border-radius: 999px;
  background: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 3.5px rgb(255 255 255 / 0.55);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform 0.45s var(--ease-spring);
}
.langs__opt {
  min-height: 34px;
  padding: 0.2rem 0.55rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--pencil);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: color 0.25s var(--ease-out), transform 0.12s var(--ease-out);
}
.langs__opt[aria-pressed='true'] { color: #fff; }
.langs__opt:hover:not([aria-pressed='true']) { color: var(--ink); }
.langs__opt:active { transform: scale(0.94); }

.switch {
  display: inline-flex;
  flex-wrap: wrap; /* at 200% text the lever drops under its name instead of pushing the page sideways */
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.25rem 0.35rem 0.25rem 0.8rem;
  border: 2px solid var(--pencil);
  border-radius: 999px;
  background: var(--card);
  color: var(--pencil);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--pencil);
  transition: transform 0.12s var(--ease-out), box-shadow 0.12s var(--ease-out);
}
.switch:hover { transform: translateY(-1px); box-shadow: 0 3px 0 var(--pencil); }
.switch:active { transform: translateY(2px); box-shadow: 0 0 0 var(--pencil); }
.switch__track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 3.5rem;
  height: 1.6rem;
  flex: none;
  border: 2px solid var(--pencil);
  border-radius: 999px;
  background: var(--paper-deep);
  overflow: hidden;
  transition: background-color 0.3s var(--ease-out);
}
.switch__state {
  position: absolute;
  right: 0.35rem;
  font: 700 0.62rem/1 var(--font-mono), var(--font-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pencil);
}
.switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.6rem - 8px);
  height: calc(1.6rem - 8px);
  border: 2px solid var(--pencil);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 1px 0 var(--pencil);
  transition: transform 0.4s var(--ease-spring);
}
.switch[aria-pressed='true'] .switch__track { background: var(--leaf); }
.switch[aria-pressed='true'] .switch__state { right: auto; left: 0.45rem; color: #fff; }
.switch[aria-pressed='true'] .switch__knob { transform: translateX(1.9rem); }
.btn, .switch { max-width: 100%; }
.switch__label { min-width: 0; overflow-wrap: anywhere; text-align: left; }

/* A little light runs across a button when you point at it. */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgb(255 255 255 / 0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.6s var(--ease-out);
  pointer-events: none;
}
.btn:hover::after { transform: translateX(120%); }
.ways-out input[type='search'] { transition: box-shadow 0.2s var(--ease-out); box-shadow: inset 0 2px 0 rgb(54 50 63 / 0.08); }
.ways-out input[type='search']:focus { box-shadow: inset 0 2px 0 rgb(54 50 63 / 0.08), 0 0 0 4px rgb(31 95 158 / 0.25); }
@media (forced-colors: active) {
  .langs::before { background: Highlight; }
  .langs__opt[aria-pressed='true'] { color: HighlightText; }
  .switch__track { border-color: ButtonText; }
}
