/* FOI Cards — touch-first mobile flashcard deck (dark app theme) */

:root {
  --ink: #edf5ff;
  --muted: #aabed4;
  --navy: #0b1728;
  --panel: #12253e;
  --line: #29496a;
  --blue: #6fc5ff;
  --green: #92e6bb;
  --amber: #ffc978;
  --red: #ff9f9d;
}

* { box-sizing: border-box; }

html { background: var(--navy); }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 0%, #1d4167 0, transparent 35%), var(--navy);
}

button { font: inherit; }

.app-shell {
  width: min(100%, 560px);
  min-height: 100dvh;
  margin: auto;
  padding: max(18px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-family: "Pinyon Script", cursive;
  font-size: 27px;
  line-height: 1;
  padding: 4px 0;
}
.brand:hover { color: #fff; }

.welcome, .completion {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 0 18px;
}

.eyebrow, .card-label {
  margin: 0 0 12px;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 11px;
  font-weight: 800;
}

h1 { margin: 0; font-size: clamp(42px, 14vw, 62px); line-height: 0.96; letter-spacing: -0.055em; }
h2 { margin: 0; font-size: clamp(26px, 8vw, 36px); line-height: 1.08; letter-spacing: -0.035em; }

.intro { margin: 20px 0 24px; font-size: 18px; line-height: 1.45; color: var(--muted); }
.summary { margin-bottom: 12px; color: var(--muted); font-size: 14px; }
.summary strong { color: var(--ink); }
.resume-hint { min-height: 18px; margin: 12px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.source-note { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 22px 4px 0; }

.primary-button, .secondary-button, .rate-button, .flip-button {
  width: 100%;
  border: 0;
  border-radius: 18px;
  min-height: 58px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button, .flip-button {
  background: var(--blue);
  color: #06111e;
  font-size: 17px;
  box-shadow: 0 12px 28px #0005;
}
.flip-button span { font-size: 20px; vertical-align: -1px; }
.secondary-button {
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  margin-top: 11px;
}
.text-button, .section-button, .close-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 0;
  font-size: 14px;
}
.centered { display: block; margin: 20px auto 0; }

.study { flex: 1; display: flex; flex-direction: column; padding-top: 14px; min-height: 0; }
.study-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.section-button {
  max-width: 62%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--blue);
  font-weight: 700;
  text-align: left;
}
.pass-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.pass-meta span:last-child { text-align: right; }
.progress-track { height: 4px; margin: 10px 0 18px; background: #213852; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--blue); border-radius: inherit; transition: width 0.25s ease; }

.card-stage { flex: 1; min-height: 330px; display: flex; align-items: center; perspective: 1300px; }
.flashcard {
  width: 100%;
  min-height: clamp(330px, 57dvh, 520px);
  outline: 0;
  cursor: pointer;
  user-select: none;
  touch-action: pan-y;
}
.card-inner {
  position: relative;
  height: 100%;
  min-height: inherit;
  transform-style: preserve-3d;
  transition: transform 0.36s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.flashcard.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  backface-visibility: hidden;
  background: linear-gradient(145deg, #193b5e, #102641);
  box-shadow: 0 20px 45px #0004;
  overflow: auto;
}
.card-back { transform: rotateY(180deg); background: linear-gradient(145deg, #143449, #102c3e); }
.card-front h2 { margin: auto 0; }
.answer { white-space: pre-line; margin: auto 0; font-size: clamp(17px, 5.2vw, 22px); line-height: 1.5; color: #f6fbff; }
.tap-hint { margin: 20px 0 0; color: var(--muted); font-size: 13px; }
.swipe-status { min-height: 20px; margin: 14px 0; color: var(--muted); text-align: center; font-size: 13px; }
.bottom-controls { min-height: 58px; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1.08fr; gap: 8px; transition: opacity 0.18s ease; }
.actions[aria-hidden="true"] { display: none; }
.rate-button { min-height: 54px; padding: 8px 5px; font-size: 12px; }
.review { color: #ffd4d2; background: #482b37; border: 1px solid #875060; }
.next { color: var(--ink); background: var(--panel); border: 1px solid var(--line); }
.mastered { color: #092416; background: var(--green); }
.rate-button span { font-size: 17px; vertical-align: -1px; }

.section-sheet {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  background: #0009;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
}
.sheet {
  width: min(100%, 528px);
  max-height: 78dvh;
  margin: auto;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #102641;
  box-shadow: 0 18px 50px #0008;
}
.sheet-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-heading h2 { font-size: 24px; }
.close-button { font-size: 28px; line-height: 1; }
.section-row {
  width: 100%;
  padding: 16px 2px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.section-row span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }

.hidden { display: none !important; }

.desktop-message { display: none; }

@media (min-width: 760px) {
  .app-shell { display: none; }
  .desktop-message {
    min-height: 100vh;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 40px;
  }
  .desktop-message > div { max-width: 430px; }
  .desktop-message h1 { font-size: 48px; }
  .desktop-message p { color: var(--muted); font-size: 18px; }
  .gate-home {
    display: inline-block;
    margin-top: 26px;
    color: var(--blue);
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
  }
  .gate-home:hover { text-decoration: underline; }
}

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