/* Atkinson Hyperlegible Next, from the Braille Institute: drawn so letters like
   I, l and 1 can't be mistaken for each other. Self-hosted, so the CSP stays
   'self'. Licence in fonts/OFL.txt. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --tile: 120px;
  /* The background's own blue, darkened until white text on it passes 7:1. */
  --accent: #1d4f73;
  --accent-dark: #143a56;
  --ink: #1f2937;
  --muted: #5b6573;
  --line: #e5e7eb;
  --card: #ffffff;
  --bg: #8ebfda;
  /* Decoration only. It is under 3:1 against both white and --bg, so it never
     carries text, focus rings or anything else someone has to be able to see. */
  --highlight: #f28207;
  --on-bg: var(--ink);
  /* --muted is too faint on the blue to read; this keeps the strapline above 4.5:1. */
  --on-bg-muted: #2f3a48;
  --radius: 12px;
  --column: 860px;
}

* { box-sizing: border-box; }

body {
  font-family: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

/* Top padding keeps the heading clear of the fixed menu on narrow screens. */
.wrap {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: var(--column);
  margin: 0 auto;
  padding: 4.5rem 1.25rem 1rem;
}

/* Scrolls away with the page rather than staying fixed like the menu, so it never
   sits on top of the results. */
.site-logo { position: absolute; top: 0.6rem; left: 1rem; line-height: 0; border-radius: 50%; }
.site-logo img { width: 128px; height: 128px; }
.site-logo:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* The menu sits in the screen's top-right corner and stays there while the page
   scrolls. Its list drops straight down beneath it. */
.site-menu { position: fixed; top: 0.9rem; right: 1rem; z-index: 20; }
.site-menu details { position: relative; }
.site-menu summary, .menu-signin {
  display: block;
  padding: 0.55rem 1rem;
  list-style: none;
  cursor: pointer;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--highlight);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.site-menu summary::-webkit-details-marker { display: none; }
.site-menu summary::after {
  content: "";
  display: inline-block;
  margin-left: 0.5rem;
  border: 5px solid transparent;
  border-top-color: currentColor;
  transform: translateY(2px);
}
.site-menu details[open] summary::after { transform: translateY(-3px) rotate(180deg); }
.site-menu ul {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: max-content;
  min-width: 100%;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 10px;
}
.site-menu li a, .site-menu li button {
  display: block;
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.site-menu li + li { border-top: 1px solid var(--line); }
.site-menu li a:hover, .site-menu li button:hover { background: #fff3e6; }
.site-menu a:focus-visible, .site-menu button:focus-visible, .site-menu summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

h1 { overflow-wrap: anywhere; margin: 0 0 1.25rem; font-size: clamp(2rem, 5.5vw, 2.9rem); line-height: 1.15; letter-spacing: -0.015em; text-align: center; color: var(--on-bg); }
.intro { margin-bottom: 1.75rem; text-align: center; }
.intro h1 { margin-bottom: 0.4rem; }
.intro p { margin: 0; color: var(--on-bg-muted); font-size: clamp(1.05rem, 2.4vw, 1.25rem); }
.note { max-width: 40rem; margin: 2rem auto 0; text-align: center; font-size: 1rem; color: var(--on-bg); }

.card {
  background: var(--card);
  border: 1px solid #6f9fbd;
  border-top: 4px solid var(--highlight);
  border-radius: var(--radius);
  padding: 1.5rem;
}

label.field { display: block; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-bottom: 0.4rem; }

textarea {
  width: 100%;
  min-height: 110px;
  padding: 0.75rem 0.9rem;
  font-size: 1.75rem;
  font-family: inherit;
  color: var(--ink);
  border: 1px solid #d1d5db;
  border-radius: 8px;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; align-items: center; }

button {
  padding: 0.6rem 1.3rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
/* The orange marks the main action. Dark text on it passes 5:1. */
.btn-primary { color: var(--ink); background: var(--highlight); border: 2px solid var(--ink); }
.btn-primary:hover:not(:disabled) { background: #f6a04a; }
.btn-secondary { color: var(--ink); background: #fff; border: 2px solid var(--ink); }
.btn-secondary:hover:not(:disabled) { background: #fff3e6; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: default; }

.status { min-height: 1.3em; margin: 0.4rem 0 0; font-size: 0.9rem; color: var(--muted); }
.status.error { color: #b91c1c; }

/* Result */
/* The results are the one thing on the page meant to stand out. */
#result {
  margin-top: 1.5rem;
  padding: 2rem 1.5rem;
  background: var(--card);
  border: 1px solid #6f9fbd;
  border-radius: var(--radius);
}
#result:empty { display: none; }

/* One block per written word: label on top, its cue row beneath. Blocks
   flow left to right and wrap, so a whole sentence stays readable. */
.cue-groups {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1.5rem 2rem;
}
.cue-group { display: flex; flex-direction: column; align-items: center; }

.result-word {
  font-size: clamp(1.5rem, 5vw, 2.6rem);
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  margin: 0 0 0.5rem;
  word-break: break-word;
}
.cue-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: flex-end;
}

.cue { display: flex; flex-direction: column; align-items: center; gap: 5px; }

.cue-tile {
  position: relative;
  width: var(--tile);
  height: var(--tile);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.cue-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

/* Stand-in shown when a cue image is missing; names the file to draw. */
.cue-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 11px; line-height: 1.3; padding: 4px;
  color: #1e3a8a; word-break: break-all;
  background: repeating-linear-gradient(45deg, #eef2ff, #eef2ff 8px, #e0e7ff 8px, #e0e7ff 16px);
}

.phoneme-label { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-ligatures: none; }


@media (max-width: 520px) {
  :root { --tile: 92px; }
  .wrap { padding: 4.75rem 1rem 2rem; }
  .site-logo img { width: 64px; height: 64px; }
  .site-bar-inner { padding: 0.6rem 1rem; }
  .card { padding: 1rem; }
}

/* Sign-in and account pages. Server-rendered, so these classes are set in
   src/pages.js rather than anywhere in this directory. */
.field-input {
  width: 100%;
  padding: 0.7rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  border: 1px solid #d1d5db;
  border-radius: 8px;
  margin-bottom: 0.9rem;
}
.card p { max-width: 70ch; }
.field-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.hint-block { font-size: 0.85rem; color: var(--muted); margin: 0.9rem 0 0; }
.card hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.card h2 { font-size: 1.05rem; margin: 0 0 0.4rem; }
.card a { color: var(--accent); }

.admin-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.9rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); }
.card h2 { margin-top: 1.5rem; }

/* Pushed to the bottom of the screen by the column above it. As faint as it can be
   while still passing 4.5:1 on the blue. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2rem 1rem;
  margin-top: auto;
  padding-top: 2.5rem;
  font-size: 0.8rem;
  color: var(--on-bg-muted);
}
.site-footer a { color: var(--on-bg-muted); }
.site-footer span { flex-basis: 100%; text-align: center; }
.card ul { padding-left: 1.25rem; max-width: 70ch; }
.card li { margin-bottom: 0.4rem; }
.card code { font-size: 0.9em; background: #eef4f8; padding: 0.1em 0.3em; border-radius: 4px; }
/* Wide tables scroll within themselves on narrow screens rather than widening the page. */
.table-scroll { overflow-x: auto; }
.site-footer a:focus-visible, .card a:focus-visible, .table-scroll:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
