/* styles.css — Bright Orange + Sky Blue theme */

/* General styles */
body {
  font-family: 'Comic Sans MS', Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #62d1e7;
  text-align: center;
  color: #ffffff;
}

/* Header styles */
header {
  background: linear-gradient(180deg, #fbb03b 0%, #ff8c42 100%);
  padding: 30px 0;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
header h1 {
  font-size: 3.2rem;
  margin: 0;
  color: #fff;
  text-shadow: 2px 2px 0 #ff5722;
}
header p {
  font-size: 1.4rem;
  margin: 10px 0 0;
  font-weight: bold;
}

/* Section card styles */
.card {
  background-color: #ffffff;
  border-radius: 20px;
  padding: 20px;
  margin: 20px auto;
  max-width: 900px;
  color: #333;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* Textarea & input */
textarea,
input[type="text"] {
  width: 90%;
  margin: 10px auto;
  padding: 12px;
  border: 3px solid #fbb03b;
  border-radius: 12px;
  font-size: 1.2rem;
  background-color: #fffdf7;
}
textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: #62d1e7;
  box-shadow: 0 0 0 4px rgba(98, 209, 231, 0.3);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  margin: 8px;
  border: none;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  background: linear-gradient(180deg, #62d1e7, #3bb8d6);
  color: #fff;
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  transition: transform 0.1s ease, filter 0.2s ease;
}
.btn.primary { background: linear-gradient(180deg, #ff9e2c, #ff7b00); }
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.96); }

/* Icon button (mic) */
.icon-btn {
  background: linear-gradient(180deg, #ff7a3d, #e95c00);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.icon-btn:hover { filter: brightness(1.05); }

/* Word list */
.word-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.word-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fffdf7;
  border: 3px solid #62d1e7;
  border-radius: 16px;
  padding: 10px 14px;
  color: #333;
  font-weight: bold;
  box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}
/* Make the word itself a themed link */
.word { font-size: 1.2rem; color: #ff7a3d; }
a.word { text-decoration: none; }
a.word:hover { text-decoration: underline; }

/* Definition UI in Quiz */
.def-box {
  margin: 10px auto 0;
  width: 90%;
  background: #fffdf7;
  border: 3px solid #62d1e7;
  border-radius: 12px;
  padding: 12px;
  color: #333;
  text-align: left;
}
.def-link {
  margin-left: 8px;
  text-decoration: underline;
}

/* Misc */
.muted { color: #666; font-weight: normal; }
.hint { color: #888; font-size: 0.9rem; }
.footer { color: #eee; margin: 20px 0; font-size: 0.9rem; }

/* Save/Load bar (page-level variant) */
.savebar {
  display: grid;
  grid-template-columns: 1.3fr auto 1.2fr auto auto auto auto;
  gap: 8px;
  align-items: center;
  justify-items: stretch;
  width: 90%;
  margin: 16px auto 0;
}
.savebar .textlike {
  padding: 10px 12px;
  border: 3px solid #62d1e7;
  border-radius: 12px;
  font-size: 1.05rem;
  background: #fffdf7;
}
.savebar select {
  padding: 10px 12px;
  border: 3px solid #62d1e7;
  border-radius: 12px;
  font-size: 1.05rem;
  background: #fffdf7;
  color: #333;
}
@media (max-width: 760px) {
  .savebar { grid-template-columns: 1fr 1fr; }
  .savebar button, .savebar select, .savebar .textlike { width: 100%; }
}

/* Smooth slide/fade for the top sections when quizzing */
.collapsible {
  overflow: hidden;
  transition:
    max-height 300ms ease,
    opacity 250ms ease,
    transform 250ms ease,
    margin 300ms ease,
    padding 300ms ease;
  will-change: max-height, opacity, transform;
}
.collapsible.open { max-height: 1000px; opacity: 1; transform: translateY(0); }
.collapsible.closed {
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) { .collapsible { transition: none; } }

/* iOS/WebKit stability: avoid transform during height transitions */
@supports (-webkit-touch-callout: none) {
  .collapsible {
    transition:
      max-height 300ms ease,
      opacity 250ms ease,
      margin 300ms ease,
      padding 300ms ease;
  }
  .collapsible.closed { transform: none; }
}

/* ========================= SETTINGS DRAWER ========================= */

/* Floating Settings button */
.settings-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  padding: 12px 16px;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(180deg, #62d1e7, #3bb8d6);
  box-shadow: 0 10px 22px rgba(0,0,0,.25);
  cursor: pointer;
}
.settings-fab:hover { filter: brightness(1.06); }
.settings-fab:active { transform: translateY(1px); }

/* Overlay: start fully hidden via display, then animate opacity */
.settings-overlay {
  position: fixed;
  inset: 0;
  display: none;                 /* hard hide by default */
  background: rgba(0,0,0,.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 1000;
}
.settings-overlay.open {
  display: block;               /* ensure visible during animation */
  opacity: 1;
  pointer-events: auto;
}
/* Extra safeguard if hidden attr is present */
.settings-overlay[hidden] { display: none !important; }

/* Drawer */
.settings-drawer {
  position: fixed;
  right: 0;
  top: 0;
  height: 100%;
  width: min(560px, 100%);
  max-width: 100%;
  background: #ffffff;
  color: #333;
  box-shadow: -10px 0 28px rgba(0,0,0,.28);
  transform: translateX(100%);      /* default: off-screen */
  transition: transform .25s ease;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  border-left: 6px solid #62d1e7;
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
  overflow: hidden;
  will-change: transform;
}

/* Keep drawer off-screen unless overlay is open */
.settings-overlay:not(.open) .settings-drawer {
  transform: translateX(100%) !important;
}

/* ⭐ When the overlay is open, slide the drawer in */
.settings-overlay.open .settings-drawer {
  transform: translateX(0) !important;
}

.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(180deg, #fbb03b 0%, #ff8c42 100%);
  color: #fff;
  border-bottom: 4px solid #ff7b00;
}
.settings-title { margin: 0; font-size: 1.2rem; letter-spacing: .2px; text-shadow: 1px 1px 0 #ff5722; }
.settings-close { border: 0; background: transparent; color: #fff; font-size: 22px; cursor: pointer; padding: 6px 10px; border-radius: 10px; }
.settings-close:hover { filter: brightness(1.08); }

.settings-content {
  padding: 16px 16px 22px;
  overflow: auto;
  background: #fff;
  color: #333;
  display: grid;
  gap: 18px;
}
.settings-section { margin: 4px 0 2px; }
.settings-section h3 { margin: 0 0 10px; font-size: 1.08rem; color: #ff7a3d; text-align: left; }

.settings-content label { display: block; text-align: left; color: #333; font-weight: 700; margin: 6px 0 6px; }
.settings-content input[type="text"],
.settings-content select {
  width: 100%; padding: 12px 14px; border: 3px solid #62d1e7; border-radius: 12px; background: #fffdf7; font-size: 1.05rem; color: #333;
}
.settings-content input::placeholder { color: #888; }
.settings-content input[type="checkbox"] { accent-color: #62d1e7; }
.settings-content input[type="range"] {
  width: 100%; accent-color: #62d1e7; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, #62d1e7, #3bb8d6);
}
.settings-content input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #ff7b00; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.settings-content .savebar {
  width: 100%; grid-template-columns: 1fr auto; gap: 10px; align-items: center; justify-items: stretch; margin: 0;
}
.settings-content .savebar .row { display: grid; grid-template-columns: repeat(4, auto); gap: 8px; }
.settings-content .stack { display: grid; gap: 12px; }
.settings-content .inline { display: inline-flex; align-items: center; gap: 8px; }
.settings-content .textlike {
  padding: 12px 14px; border: 3px solid #62d1e7; border-radius: 12px; background: #fffdf7; font-size: 1.05rem; color: #333;
}

/* Small screens */
@media (max-width: 560px) {
  .settings-content .savebar { grid-template-columns: 1fr; }
  .settings-content .savebar .row { grid-template-columns: 1fr 1fr; }
  .settings-content .savebar .row .btn { width: 100%; }
}

/* === Big, legible spelling display === */
.quiz-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

/* The revealed spelling sits on its own line and is BIG */
#spelling {
  display: block;                 /* own line */
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  font-size: clamp(2.25rem, 6.5vw, 3.75rem); /* big + responsive */
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #ff7a3d;                 /* themed orange */
  text-align: center;
  background: #fffdf7;
  border: 3px solid #62d1e7;
  border-radius: 14px;
  overflow-wrap: anywhere;        /* long words never overflow */
}

/* Make the answer box easier to read/type */
#answer {
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  padding: 14px 16px;
}

/* Nudge quiz buttons a touch larger without breaking layout */
.quiz-bar .btn,
.quiz-actions .btn {
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  padding: 12px 18px;
  min-height: 44px;               /* comfy tap target */
}

/* Definition box: slightly larger body text */
.def-box {
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  line-height: 1.4;
}
