/* AP Latin Vocabulary Study — mobile-first (phone is primary) */

.alv-tool {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Soft wash only — classical décor is in .alv-bg side rails */
body.alv-tool {
  background-color: var(--ai-bg-page);
  background-image:
    radial-gradient(ellipse 85% 50% at 50% -5%, rgba(26, 115, 232, 0.05), transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, var(--ai-bg-page) 100%);
}

/*
 * Side rails hug the tool column (mottos inward, art outward):
 *   [pics | mottos] TOOL [mottos | pics]
 * Center track matches .alv-page width so décor never sits under cards.
 */
.alv-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: grid;
  grid-template-columns: 1fr minmax(0, 720px) 1fr;
  align-items: stretch;
  padding: 48px 8px 16px;
  box-sizing: border-box;
  column-gap: 12px;
}

.alv-bg__center {
  /* Empty spacer matching the tool column */
  min-width: 0;
}

.alv-bg__side {
  max-width: 340px;
  min-width: 0;
  display: flex;
  flex-direction: row;
  gap: 14px;
  overflow: hidden;
  width: 100%;
}

/* Left rail sits against the tool’s left edge */
.alv-bg__side--left {
  grid-column: 1;
  justify-self: end;
  justify-content: flex-end;
  padding-right: 4px;
}
.alv-bg__side--left .alv-bg__pics { order: 1; }
.alv-bg__side--left .alv-bg__mottos { order: 2; }

/* Right rail sits against the tool’s right edge */
.alv-bg__side--right {
  grid-column: 3;
  justify-self: start;
  justify-content: flex-start;
  padding-left: 4px;
}
.alv-bg__side--right .alv-bg__mottos { order: 1; text-align: right; }
.alv-bg__side--right .alv-bg__pics { order: 2; }

.alv-bg__center {
  grid-column: 2;
}

.alv-bg__pics {
  flex: 0 0 auto;
  width: clamp(100px, 11vw, 168px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
  padding: 2px 0;
  gap: 10px;
}

.alv-bg__pics img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* Scale accents within the pic stack */
.alv-bg__pics img.alv-bg__pic--column {
  width: 88%;
  max-height: 32vh;
  object-fit: contain;
}

.alv-bg__pics img.alv-bg__pic--scroll {
  width: 92%;
}

.alv-bg__pics img.alv-bg__pic--laurel {
  width: 78%;
}

.alv-bg__mottos {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  min-width: 0;
  max-width: 11.5rem;
  padding: 4px 0;
}

.alv-bg__motto {
  margin: 0;
  font-family: "Times New Roman", Times, Georgia, serif;
  font-style: italic;
  color: rgba(0, 48, 135, 0.17);
  line-height: 1.25;
}

.alv-bg__motto strong {
  display: block;
  font-weight: 700;
  font-size: clamp(0.9rem, 1.15vw, 1.25rem);
}

.alv-bg__motto span {
  display: block;
  font-size: clamp(0.68rem, 0.85vw, 0.8rem);
  color: rgba(26, 115, 232, 0.18);
  margin-top: 0.15rem;
}

.alv-bg__motto em {
  display: block;
  font-size: clamp(0.62rem, 0.78vw, 0.72rem);
  color: rgba(179, 138, 18, 0.2);
  margin-top: 0.1rem;
}

.alv-bg__spqr {
  margin: 0.25rem 0;
  padding: 0.3rem 0.55rem;
  border: 1px solid rgba(0, 48, 135, 0.16);
  border-radius: 3px;
  color: rgba(0, 48, 135, 0.17);
  font-family: "Times New Roman", Times, Georgia, serif;
  font-weight: 700;
  font-size: clamp(0.75rem, 1vw, 0.95rem);
  letter-spacing: 0.16em;
  text-align: center;
  align-self: center;
}

body.alv-tool > .ai-container {
  position: relative;
  z-index: 1;
}

/* Tool column sits above décor; solid enough that side rails never read as “under” cards */
.alv-page {
  position: relative;
  z-index: 1;
}

/* Hide rails when there isn’t room for two side columns */
@media (max-width: 1100px) {
  .alv-bg {
    display: none;
  }
}

@media print {
  .alv-bg {
    display: none;
  }
}

.alv-page-title {
  font-size: 1.4rem;
  margin: 0;
}

.alv-page {
  max-width: 720px;
  padding-bottom: 48px;
}

.alv-hero {
  text-align: center;
  padding: 20px 16px 12px;
  /* Soft scrim so Latin bg doesn't compete with hub copy */
  background: radial-gradient(
    ellipse 95% 90% at 50% 45%,
    rgba(248, 250, 252, 0.96) 0%,
    rgba(248, 250, 252, 0.88) 50%,
    transparent 78%
  );
}

.alv-hero h2 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  color: var(--ai-blue-800);
  font-weight: 700;
}

.alv-hero p {
  margin: 0;
  color: var(--ai-gray-600);
  font-size: 1rem;
  line-height: 1.45;
}

.alv-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.alv-stat {
  background: var(--ai-bg-card);
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-lg);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--ai-shadow-sm);
}

.alv-stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ai-blue-800);
  line-height: 1.1;
}

.alv-stat-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ai-gray-600);
  margin-top: 4px;
}

.alv-stat.streak .alv-stat-value {
  color: #b45309;
}

.alv-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.alv-filters label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ai-gray-700);
}

.alv-filters select {
  flex: 1;
  min-width: 120px;
  padding: 12px 14px;
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-md);
  font-size: 1rem;
  background: white;
  min-height: 48px;
}

.alv-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 520px) {
  .alv-mode-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.alv-mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  background: var(--ai-bg-card);
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-lg);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: var(--ai-shadow-sm);
  font-family: inherit;
  color: inherit;
  width: 100%;
}

.alv-mode-card:hover,
.alv-mode-card:focus-visible {
  border-color: var(--ai-blue-600);
  box-shadow: var(--ai-shadow-md);
  outline: none;
}

.alv-mode-card:active {
  transform: scale(0.98);
}

.alv-mode-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.alv-mode-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ai-blue-800);
}

.alv-mode-desc {
  font-size: 0.9rem;
  color: var(--ai-gray-600);
  line-height: 1.4;
}

.alv-mode-card.featured {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #f0f6ff 0%, #fff 60%);
  border-color: #93c5fd;
}

.alv-mode-card.featured .alv-mode-body {
  flex: 1;
}

.alv-mode-card.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Study session */
.alv-session {
  display: none;
}

.alv-session.active {
  display: block;
}

.alv-home.active {
  display: block;
}

.alv-home.hidden {
  display: none;
}

.alv-session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.alv-back {
  background: none;
  border: none;
  color: var(--ai-blue-600);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 4px;
  min-height: 44px;
  font-family: inherit;
}

.alv-progress {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  color: var(--ai-gray-600);
  font-weight: 600;
}

.alv-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ai-blue-800);
  min-width: 48px;
  text-align: right;
}

.alv-progress-bar {
  height: 6px;
  background: var(--ai-gray-200);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.alv-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ai-blue-600), var(--ai-gold));
  border-radius: 999px;
  transition: width 0.25s ease;
  width: 0%;
}

/* Flashcard */
.alv-card-scene {
  perspective: 1200px;
  margin-bottom: 20px;
  min-height: 220px;
}

.alv-card {
  position: relative;
  width: 100%;
  min-height: 220px;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.alv-card.flipped {
  transform: rotateY(180deg);
}

.alv-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--ai-bg-card);
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-xl);
  padding: 28px 20px;
  box-shadow: var(--ai-shadow-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.alv-card-back {
  transform: rotateY(180deg);
}

.alv-card-lemma {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ai-blue-800);
  font-family: "Palatino Linotype", Palatino, "Times New Roman", serif;
  margin-bottom: 8px;
}

.alv-card-forms {
  font-size: 0.9rem;
  color: var(--ai-gray-600);
  font-family: var(--ai-font-mono);
  line-height: 1.4;
  max-width: 100%;
  word-break: break-word;
}

.alv-card-pos {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #e8f0fe;
  color: var(--ai-blue-700);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.alv-card-def {
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ai-gray-800);
  max-width: 100%;
}

.alv-card-reading {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--ai-gray-500);
}

.alv-tap-hint {
  font-size: 0.75rem;
  color: var(--ai-gray-500);
  margin-top: 10px;
}

.alv-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.alv-actions.two {
  grid-template-columns: 1fr 1fr;
}

.alv-btn {
  padding: 16px 14px;
  border: none;
  border-radius: var(--ai-radius-lg);
  font-size: 1.05rem;
  font-weight: 600;
  min-height: 52px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.15s;
  touch-action: manipulation;
}

.alv-btn:active {
  transform: scale(0.97);
}

.alv-btn.good {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.alv-btn.miss {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.alv-btn.neutral {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.alv-btn.primary {
  background: var(--ai-blue-600);
  color: white;
}

.alv-btn.secondary {
  background: white;
  color: var(--ai-blue-700);
  border: 1px solid var(--ai-gray-200);
}

/* Multiple choice */
.alv-question {
  background: var(--ai-bg-card);
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-xl);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: var(--ai-shadow-sm);
}

.alv-question-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ai-gray-500);
  margin-bottom: 10px;
}

.alv-question-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.alv-question-text {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ai-blue-800);
  font-family: "Palatino Linotype", Palatino, "Times New Roman", serif;
  line-height: 1.35;
}

.alv-question-text.def {
  font-family: var(--ai-font-sans);
  font-size: 1.15rem;
  font-weight: 500;
  text-align: left;
  flex: 1 1 100%;
}

.alv-question-forms {
  margin-top: 10px;
  font-size: 1rem;
  color: var(--ai-gray-600);
  font-family: var(--ai-font-mono);
  line-height: 1.45;
  word-break: break-word;
}

/* Part of speech badges — avoid site blue, green (correct), red (wrong), gold (streak) */
.alv-pos-badge {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.alv-pos-noun { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.alv-pos-verb { background: #ffedd5; color: #c2410c; border-color: #fdba74; }
.alv-pos-adjective { background: #ccfbf1; color: #0f766e; border-color: #5eead4; }
.alv-pos-adverb { background: #fce7f3; color: #be185d; border-color: #f9a8d4; }
.alv-pos-preposition { background: #f5f5f4; color: #57534e; border-color: #d6d3d1; }
.alv-pos-conjunction { background: #ecfccb; color: #3f6212; border-color: #bef264; }
.alv-pos-pronoun { background: #fae8ff; color: #86198f; border-color: #e879f9; }
.alv-pos-pronoun-adj { background: #f3e8ff; color: #7e22ce; border-color: #d8b4fe; }
.alv-pos-prep-adv { background: #fafaf9; color: #44403c; border-color: #e7e5e4; }
.alv-pos-adj-adv { background: #d1fae5; color: #047857; border-color: #6ee7b7; }
.alv-pos-interjection { background: #fef3c7; color: #a16207; border-color: #fcd34d; }

.alv-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alv-option {
  padding: 18px 16px;
  text-align: left;
  background: white;
  border: 2px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-lg);
  font-size: 1.1rem;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.5;
  min-height: 56px;
  transition: border-color 0.12s, background 0.12s;
  touch-action: manipulation;
}

.alv-option:hover:not(:disabled) {
  border-color: var(--ai-blue-500);
}

.alv-option.correct {
  border-color: #22c55e;
  background: #f0fdf4;
}

.alv-option.wrong {
  border-color: #ef4444;
  background: #fef2f2;
}

.alv-option:disabled {
  cursor: default;
}

.alv-option-main {
  display: block;
}

.alv-option-reveal {
  display: block;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--ai-gray-200);
  font-size: 0.82rem;
  color: var(--ai-gray-600);
  line-height: 1.35;
}

.alv-option.correct .alv-option-reveal {
  border-top-color: #bbf7d0;
  color: #166534;
}

.alv-option.wrong .alv-option-reveal {
  border-top-color: #fecaca;
}

.alv-option-reveal .alv-latin {
  font-family: "Palatino Linotype", Palatino, "Times New Roman", serif;
  font-weight: 700;
  color: var(--ai-blue-800);
  font-size: 0.95rem;
}

.alv-mc-next {
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  font-size: 1rem;
}

.alv-feedback {
  text-align: center;
  margin-top: 16px;
  min-height: 24px;
  font-weight: 600;
  font-size: 0.95rem;
}

.alv-feedback.ok { color: #166534; }
.alv-feedback.bad { color: #991b1b; }

/* Timed mode setup */
.alv-timed-setup {
  padding: 8px 0 24px;
}

.alv-setup-back {
  margin-bottom: 12px;
}

.alv-timed-setup h3 {
  margin: 0 0 6px;
  text-align: center;
  color: var(--ai-blue-800);
  font-size: 1.35rem;
}

.alv-setup-intro {
  text-align: center;
  color: var(--ai-gray-600);
  font-size: 0.9rem;
  margin: 0 0 24px;
  line-height: 1.45;
}

.alv-setup-section {
  margin-bottom: 20px;
}

.alv-setup-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ai-gray-600);
  margin-bottom: 10px;
}

.alv-timing-toggle {
  display: flex;
  gap: 8px;
}

.alv-timing-toggle button {
  flex: 1;
  padding: 12px 10px;
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-lg);
  background: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.alv-timing-toggle button.active {
  background: #1e3a5f;
  color: white;
  border-color: #1e3a5f;
}

.alv-duration-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.alv-duration-presets button {
  padding: 12px 8px;
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-lg);
  background: white;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--ai-gray-700);
}

.alv-duration-presets button.active {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.alv-duration-presets button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.alv-timed-go {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  margin-top: 8px;
}

.alv-timed-finish {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: var(--ai-radius-md);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* Timed results */
.alv-results {
  text-align: center;
  padding: 32px 16px;
}

.alv-results h3 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  color: var(--ai-blue-800);
}

.alv-results .score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--ai-gold-dark);
  margin: 16px 0;
}

.alv-results p {
  color: var(--ai-gray-600);
  margin: 0 0 20px;
}

/* Browse */
.alv-search {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-lg);
  font-size: 1rem;
  margin-bottom: 12px;
}

.alv-word-list {
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-lg);
  background: white;
}

.alv-word-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ai-gray-100);
  cursor: pointer;
}

.alv-word-item:last-child {
  border-bottom: none;
}

.alv-word-item:hover {
  background: #f8fafc;
}

.alv-word-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.alv-word-item-lemma {
  font-weight: 700;
  color: var(--ai-blue-800);
  font-family: "Palatino Linotype", Palatino, serif;
}

.alv-word-item-pos {
  font-size: 0.7rem;
  color: var(--ai-gray-500);
  text-transform: uppercase;
}

.alv-word-item-def {
  font-size: 0.85rem;
  color: var(--ai-gray-600);
  margin-top: 4px;
  line-height: 1.35;
}

.alv-word-item.weak {
  border-left: 3px solid #f59e0b;
}

.alv-word-item.strong {
  border-left: 3px solid #22c55e;
}

.alv-direction-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.alv-direction-toggle button {
  flex: 1;
  padding: 14px 10px;
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-md);
  background: white;
  font-size: 1rem;
  font-weight: 600;
  min-height: 48px;
  cursor: pointer;
  font-family: inherit;
}

.alv-direction-toggle button.active {
  background: var(--ai-blue-600);
  color: white;
  border-color: var(--ai-blue-600);
}

.alv-credit {
  text-align: center;
  font-size: 0.75rem;
  color: var(--ai-gray-500);
  margin-top: 24px;
  line-height: 1.5;
}

.alv-reset-progress {
  display: block;
  margin: 12px auto 0;
  padding: 8px 14px;
  background: none;
  border: 1px solid var(--ai-gray-200);
  border-radius: var(--ai-radius-md);
  color: var(--ai-gray-600);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}

.alv-reset-progress:hover {
  border-color: #fca5a5;
  color: #991b1b;
  background: #fef2f2;
}

.alv-session-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.alv-pill {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ai-gray-100);
  color: var(--ai-gray-700);
}

@media (max-width: 520px) {
  .alv-mode-grid {
    grid-template-columns: 1fr;
  }
}