/* Brilliant French hub. Its own look: the apps keep theirs. */

:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1c1b19;
  --muted: #6b675f;
  --line: #e3ded3;
  --accent: #1f4e79;
  --accent-text: #ffffff;
  --danger: #a12a1f;
  --ok: #2e7d4f;
  --warn-bg: #fff4d6;
  --warn-line: #e8cf86;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --card: #1f1f1d;
    --text: #f1efe9;
    --muted: #a29e94;
    --line: #34322e;
    --accent: #9cc3ea;
    --accent-text: #10202f;
    --danger: #ef8a7f;
    --ok: #7fcf9c;
    --warn-bg: #3a3218;
    --warn-line: #6b5a24;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

.brand {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

.brand a { color: inherit; text-decoration: none; }

.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0 0 0.8rem; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  min-height: 44px;
  padding: 0.4rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

button.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0;
  min-height: 0;
  text-decoration: underline;
}

input[type="text"], input[type="password"], select {
  min-height: 44px;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

/* ---- Login ---- */

.login {
  width: min(22rem, 100% - 2rem);
  margin: 18vh auto 0;
}

.login .brand { font-size: 2rem; margin-bottom: 0.3rem; }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 1rem;
}

/* ---- Gateway ---- */

.page {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.top .brand { font-size: 1.7rem; }

.top nav {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.top nav form { margin: 0; }

.page.gateway {
  max-width: 82rem;
  padding: 1rem 1.5rem 2rem;
}

.hello {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  letter-spacing: 0.01em;
  line-height: 1.2;
  margin: 0;
}

/* Sits in the header line, between the greeting and the links. */
.banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  margin: 0;
  font-size: 0.85rem;
}

[hidden] { display: none !important; }

/* Three across and two down on a computer, so all six fit on one screen. */

.tiles {
  list-style: none;
  margin: 1.1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 40rem) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.25rem; }
}

@media (min-width: 62rem) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem 2.75rem; }
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1.1rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease;
}

.tile:not(.off):hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.tile:has(h2 a:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.tile.off { opacity: 0.6; }

.tile h2 {
  margin: 0.1rem 0 0.75rem;
  text-align: center;
  font-size: 1.75rem;
  line-height: 1.15;
}

.tile h2 .wordmark { font-size: calc(1em * var(--wm-scale, 1)); }

.tile h2 a {
  color: inherit;
  text-decoration: none;
  outline: none;
}

/* The whole card opens the app, apart from the carousel. */
.tile h2 a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.tile h3 {
  margin: 0.7rem 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.tile ul {
  margin: 0;
  padding-left: 1.05rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.42;
}

.tile li + li { margin-top: 0.1rem; }

.soon {
  margin: 0.8rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

/* ---- App names, each in the style of the app's own title ---- */

.wordmark .accent { color: var(--wm-accent, inherit); }

.wm-audiobooks {
  font-family: "Literata", Georgia, serif;
  font-weight: 900;
  letter-spacing: -0.015em;
  --wm-accent: #9a7430;
}

.wm-grammar-drills {
  font-family: "DM Serif Display", Georgia, serif;
  font-weight: 400;
  color: #1f2b4d;
  --wm-accent: #e3503f;
  --wm-scale: 1.08;
}

.wm-discuss-the-news {
  font-family: var(--serif);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  --wm-scale: 0.8;
}

.wm-flashcards {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  --wm-accent: #2b4c8c;
}

.wm-flashcards .accent { font-style: italic; }

.wm-diary {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-weight: 600;
  letter-spacing: -0.03em;
  --wm-accent: #5f9e4d;
  --wm-scale: 0.9;
}

/* The Diary's typing cursor. */
.wm-diary::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 0.95em;
  margin-left: 0.12em;
  vertical-align: -0.12em;
  background: var(--wm-accent);
}

.wm-verb-cube {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 800;
  letter-spacing: -0.025em;
  --wm-accent: #2e7d32;
  --wm-scale: 0.96;
}

@media (prefers-color-scheme: dark) {
  .wm-audiobooks { --wm-accent: #d6b478; }
  .wm-grammar-drills { color: inherit; --wm-accent: #f07563; }
  .wm-flashcards { --wm-accent: #9db8ef; }
  .wm-diary { --wm-accent: #8fca7c; }
  .wm-verb-cube { --wm-accent: #6cc070; }
}

/* ---- Screenshot carousel ---- */

.carousel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
  box-shadow: 0 0 0 1px var(--line);
}

/* On a computer the screenshots shrink with the window's height, so both
   rows of cards stay on screen. Click one for the big version. */
@media (min-width: 62rem) {
  .carousel { max-width: clamp(12rem, calc((100vh - 34.25rem) * 0.8), 20rem); }
}

.slides {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  outline: none;
}

.slides::-webkit-scrollbar { display: none; }

.carousel:has(.slides:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.slide {
  position: relative;
  flex: 0 0 100%;
  margin: 0;
  scroll-snap-align: start;
  cursor: zoom-in;
}

.slide img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 800 / 499;
  object-fit: cover;
}

.carousel .slide-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #1c1b19;
  font-size: 1.2rem;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.carousel .prev { left: 6px; }
.carousel .next { right: 6px; }

.carousel:hover .slide-nav,
.carousel .slide-nav:focus-visible { opacity: 1; }

@media (hover: none) {
  .carousel .slide-nav { display: none; }
}

.dots {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
}

.carousel .dot {
  width: 7px;
  height: 7px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}

.carousel .dot[aria-current="true"] { background: #fff; }

.carousel.single .slide-nav,
.carousel.single .dots { display: none; }

/* ---- Screenshot preview ---- */

.preview {
  width: min(52rem, 100% - 2rem);
  max-height: calc(100vh - 2rem);
  padding: 0.9rem 1.1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.preview::backdrop { background: rgba(8, 8, 8, 0.75); }

.preview-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
}

.preview-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin: 0;
}

.preview-count {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.preview .preview-close {
  margin-left: auto;
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 1.7rem;
  line-height: 1;
}

.preview .preview-close:hover { background: var(--bg); }

.preview-frame { position: relative; }

.preview-frame img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 12rem);
  aspect-ratio: 800 / 499;
  object-fit: contain;
  border-radius: 10px;
  background: var(--line);
  user-select: none;
  touch-action: pan-y;
}

.preview .preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #1c1b19;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}

.preview .prev { left: 10px; }
.preview .next { right: 10px; }

.preview.single .preview-nav { display: none; }

.preview-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.2rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.preview-caption {
  margin: 0;
  font-size: 1.02rem;
}

.preview-open {
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.preview-open:hover { text-decoration: underline; }

/* ---- No access ---- */

.noaccess {
  width: min(30rem, 100% - 2rem);
  margin: 12vh auto 3rem;
}

.noaccess h1 {
  font-family: var(--serif);
  font-size: clamp(1.45rem, 4.5vw, 1.85rem);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.4rem;
}

.noaccess h1 .wordmark {
  font-size: calc(1em * var(--wm-scale, 1));
  white-space: nowrap;
}

.access {
  list-style: none;
  margin: 1rem 0 1.6rem;
  padding: 0;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.access li {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1.1rem;
}

.access li + li { border-top: 1px solid var(--line); }

.access li.this { background: color-mix(in srgb, var(--danger) 7%, transparent); }

.access .wordmark {
  font-size: calc(1.15rem * var(--wm-scale, 1));
  line-height: 1.2;
}

.access a { color: inherit; text-decoration: none; }

.access .no .wordmark {
  color: var(--muted);
  --wm-accent: var(--muted);
}

/* A drawn checkbox: ticked for the apps this person can open. */
.box {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border: 2px solid color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: 6px;
}

.yes .box {
  background: var(--ok);
  border-color: var(--ok);
}

.yes .box::after {
  content: "";
  width: 0.36rem;
  height: 0.7rem;
  margin-top: -0.15rem;
  border: solid var(--card);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 1.15rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}

.back:hover { filter: brightness(1.08); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Admin ---- */

.admin h2 {
  font-family: var(--serif);
  font-size: 1.3rem;
  margin: 2rem 0 0.8rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}

.add-form {
  display: grid;
  gap: 0.8rem;
}

.add-form .row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.add-form input[type="text"] { flex: 1 1 12rem; }

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}

.checks label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}

th, td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th { font-weight: 600; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
tr.disabled td { color: var(--muted); }

.actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
}

.tag {
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tag.warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--text); }

.status {
  min-height: 1.5rem;
  margin: 0.6rem 0 0;
  font-size: 0.92rem;
}

.status.bad { color: var(--danger); }
.status.good { color: var(--ok); }

.period {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.total {
  font-family: var(--serif);
  font-size: 1.6rem;
  margin: 0.2rem 0 0;
}
