/* Cell modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(44, 36, 25, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.quiz-reward-backdrop {
  z-index: 250;
}

/* 祝贺弹窗在 main 外，必须用 #quiz-reward-modal 限定（勿写在 #page-quiz 内） */
#quiz-reward-modal .modal.quiz-reward-modal {
  text-align: center;
  max-width: 360px;
  overflow: hidden;
}

#quiz-reward-modal .quiz-reward-image-wrap {
  position: relative;
  width: 100%;
  height: 200px;
  margin: 0 auto 20px;
  padding: 0;
  overflow: hidden;
  background: color-mix(in srgb, var(--present) 12%, var(--card));
  border-radius: 16px;
  box-sizing: border-box;
}

#quiz-reward-modal #quiz-reward-image {
  position: absolute;
  top: 12px;
  left: 16px;
  width: calc(100% - 32px);
  height: calc(100% - 24px);
  max-width: calc(100% - 32px);
  max-height: calc(100% - 24px);
  margin: 0;
  padding: 0;
  border: none;
  object-fit: contain;
  object-position: center;
  box-sizing: border-box;
}

.modal {
  width: 100%;
  max-width: min(400px, calc(100vw - 32px));
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(44, 36, 25, 0.2);
  padding: 24px;
  transform: translateY(8px);
  transition: transform 0.2s ease;
}

.modal-backdrop.is-open .modal { transform: translateY(0); }

.modal-tense {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
}

.modal-meta {
  margin: 0 0 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.modal-form {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.modal-example {
  font-size: inherit;
  line-height: inherit;
}

.modal-translation {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.modal-close {
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.modal-close:hover { background: var(--paper-deep); }

/* Tense usage reference (Verb Search matrix head) */
.tense-usage-backdrop {
  z-index: 220;
}

.modal--tense-usage {
  max-width: min(440px, calc(100vw - 32px));
  max-height: min(86vh, 720px);
  overflow: auto;
  padding: 22px 22px 20px;
  position: relative;
}

/* Présent only: cooler panel so yellow usage labels stay readable */
.modal--tense-usage[data-tense-id="present"] {
  background: #f7f8f6;
}

.modal--tense-usage[data-tense-id="present"] .tense-usage-timeline {
  background: rgba(44, 36, 25, 0.05);
}

.tense-usage-modal-x {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #6b6358);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.tense-usage-modal-x:hover {
  background: rgba(44, 36, 25, 0.06);
  color: var(--text);
}

.tense-usage-modal-title {
  margin: 0 36px 14px 0;
  font-family: var(--serif, Georgia, serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}

.tense-usage-modal-body {
  margin-bottom: 16px;
}

.tense-usage-timeline {
  margin: 0 0 18px;
  padding: 14px 8px 10px;
  background: color-mix(in srgb, var(--tense-accent, #E8C45A) 12%, var(--card, #fff));
  border-radius: 12px;
}

.tense-usage-timeline-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 4px 10px;
}

.tense-usage-timeline-arrow {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-style: solid;
}

.tense-usage-timeline-arrow--left {
  border-width: 5px 8px 5px 0;
  border-color: transparent rgba(44, 36, 25, 0.55) transparent transparent;
}

.tense-usage-timeline-arrow--right {
  border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent rgba(44, 36, 25, 0.55);
}

.tense-usage-timeline-track {
  position: relative;
  flex: 1 1 auto;
  height: 14px;
  margin: 0;
}

.tense-usage-timeline-track::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1.5px;
  transform: translateY(-50%);
  background: rgba(44, 36, 25, 0.45);
}

.tense-usage-timeline-mark {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 12px;
  height: 12px;
  margin: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
}

.tense-usage-timeline-mark--event {
  background: var(--tense-accent, #E8C45A);
  border: 2px solid var(--tense-accent, #E8C45A);
}

.tense-usage-timeline-mark--now {
  width: 8px;
  height: 8px;
  background: #9a9288;
  border: 1.5px solid #7a736a;
  box-shadow: none;
}

.tense-usage-timeline-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted, #6b6358);
  text-transform: lowercase;
}

/* Timeline mark positions by tense (match tenses.pages sketches) */
.tense-usage-timeline[data-kind="present"] .tense-usage-timeline-mark--event {
  left: 50%;
}
.tense-usage-timeline[data-kind="present"] .tense-usage-timeline-mark--now {
  display: none;
}

.tense-usage-timeline[data-kind="pc"] .tense-usage-timeline-mark--event {
  left: 28%;
}
.tense-usage-timeline[data-kind="pc"] .tense-usage-timeline-mark--now {
  left: 50%;
}

.tense-usage-timeline[data-kind="imparfait"] .tense-usage-timeline-track::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 56%;
  top: 50%;
  z-index: 1;
  height: 6px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: repeating-linear-gradient(
    90deg,
    var(--tense-accent, #5CAD6E) 0 7px,
    transparent 7px 12px
  );
}
.tense-usage-timeline[data-kind="imparfait"] .tense-usage-timeline-mark--event {
  display: none;
}
.tense-usage-timeline[data-kind="imparfait"] .tense-usage-timeline-mark--now {
  left: 50%;
}

.tense-usage-timeline[data-kind="futur"] .tense-usage-timeline-mark--now {
  left: 50%;
}
.tense-usage-timeline[data-kind="futur"] .tense-usage-timeline-mark--event {
  left: 78%;
}

.tense-usage-timeline[data-kind="conditionnel"] .tense-usage-timeline-mark--now {
  left: 50%;
}
.tense-usage-timeline[data-kind="conditionnel"] .tense-usage-timeline-mark--event {
  left: 78%;
  background: color-mix(in srgb, var(--tense-accent, #A58AD6) 38%, #fff);
  border: 2px dashed var(--tense-accent, #A58AD6);
}

.tense-usage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tense-usage-item {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid rgba(44, 36, 25, 0.08);
}

.tense-usage-item:last-child {
  border-bottom: none;
}

.tense-usage-item-toggle {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 10px 2px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--tense-accent, #E8C45A);
}

.tense-usage-item-toggle:hover {
  filter: brightness(0.92);
}

.tense-usage-item-chevron {
  flex: 0 0 auto;
  width: 0.7em;
  margin-top: 0.15em;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--tense-accent, #E8C45A);
  opacity: 0.85;
  transition: transform 0.12s ease;
}

.tense-usage-item.is-open .tense-usage-item-chevron {
  transform: rotate(90deg);
}

.tense-usage-item-usage {
  margin: 0;
  flex: 1 1 auto;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--tense-accent, #E8C45A);
  line-height: 1.35;
}

.tense-usage-num {
  display: inline-block;
  min-width: 1.1em;
  font-weight: 700;
  color: inherit;
  opacity: 0.85;
}

.tense-usage-item-body {
  display: none;
  padding: 0 2px 12px 1.35em;
}

.tense-usage-item.is-open .tense-usage-item-body {
  display: block;
}

.tense-usage-item-fr {
  margin: 0 0 2px;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text);
}

.tense-usage-item-en {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted, #6b6358);
}

#tense-usage-modal .modal-close {
  width: 100%;
  margin-top: 4px;
}
