/* ======================================================
   RESET & BASE
====================================================== */

* {
  box-sizing: border-box;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Segoe UI Emoji",
    "Apple Color Emoji",
    "Noto Color Emoji",
    sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0f1117;
  color: #e6e6e6;
}


/* ======================================================
   TOP BAR
====================================================== */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background: #161a22;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .5);
}

.top-bar h1 {
  margin: 0;
  font-size: 1.1em;
}


/* ======================================================
   MAIN LAYOUT
====================================================== */

.layout {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 84px 20px 110px;
  min-height: 100vh;
}

.app {
  width: min(420px, 100%);
  background: #161a22;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 0 30px rgba(0, 0, 0, .6);

  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}


/* ======================================================
   PLAY AREA
====================================================== */

#play-area {
  margin: 20px 0;
}

#play-area input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: #1e2333;
  color: #fff;
  margin-top: 12px;
}

#play-area input:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3b82f6;
}


/* ======================================================
   MODE TITLE
====================================================== */

.mode-title {
  margin: 4px 0 14px;
  text-align: center;
  font-size: 1.2em;
  font-weight: 600;
  color: #cbd5f5;
}


/* ======================================================
   SESSION STATS ROW
====================================================== */

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #1e2333;
  font-size: 0.9em;
  color: #c7c7c7;
}

.stats-row strong {
  color: #e5e7eb;
  font-size: x-large;
}


/* ======================================================
   CARD
====================================================== */

.card {
  width: 100%;
  height: 10%;
  perspective: 1000px;
  cursor: pointer;

}

.card-inner {
  position: relative;
  width: 100%;
  height: clamp(220px, 40vh, 360px);
  transform-style: preserve-3d;
  transition: transform .6s ease;
}

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


/* ======================================================
   CARD FACE
====================================================== */

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: pre-line;
  backface-visibility: hidden;
  background: #0f1320;
  transition: background-color .35s ease, box-shadow .35s ease;

  padding: clamp(20px, 4vw, 36px);
  font-size: clamp(1.2em, 2.5vw, 1.6em);
}

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

.card-text {
  max-width: 100%;
  line-height: 1.4;
  pointer-events: none;
}



/* ======================================================
   CARD META
====================================================== */

.card-meta {
  position: absolute;
  top: 10%;
  left: 10%;
  display: inline-flex;   /* IMPORTANT */
  align-items: center;
  gap: 8px;
  white-space: nowrap;   /* IMPORTANT */
  font-size: x-large;
  color: #9ca3af;
  user-select: none;
}

/* test */


.card-meta {

  display: flex;
  align-items: center;
  gap: 8px;
}

/* ======================================================
   CARD FEEDBACK
====================================================== */

.card.correct .card-face {
  background: #064e3b;
  box-shadow: 0 0 25px rgba(16, 185, 129, .7);
}

.card.wrong .card-face {
  background: #7f1d1d;
  box-shadow: 0 0 25px rgba(239, 68, 68, .7);
}

.card.wrong:not(.flipped) .card-face {
  animation: soft-flash .35s;
}

@keyframes soft-flash {
  from {
    background-color: #7f1d1d;
  }

  to {
    background-color: #0f1320;
  }
}


/* ======================================================
   TTS BUTTON
====================================================== */

.tts-btn {
  position: absolute;
  top: 3%;
  right: 10%;
  background: none;
  border: none;
  font-size: 1.1em;
  color: #9ca3af;
  cursor: pointer;
  z-index: 10;
  margin-top: 20px;
}

.tts-btn:hover {
  color: #e5e7eb;
}



/* ======================================================
   SIDE PANELS
====================================================== */

.casual-panel,
.ranked-panel {
  width: 20%;
  background: #161a22;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 0 30px rgba(0, 0, 0, .6);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: larger;
}

.ranked-panel {
  visibility: visible;
}

.casual-panel h2,
.ranked-panel h2 {
  margin: 0 0 6px;
  text-align: center;
  font-size: 1.1em;
  color: #cbd5f5;
}

.stat {
  display: flex;
  justify-content: space-between;
  font-size: .9em;
  color: #c7c7c7;
  font-size: x-large;
}

.casual-panel hr,
.ranked-panel hr {
  border: none;
  border-top: 1px solid #2a2f3f;
  margin: 6px 0;
}

.casual-rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: x-large;
}

.casual-rank img {
  width: min(100%, 60vw);
  margin-top: -30%;
  margin-bottom: -20%;
  height: auto;
}

.casual-rank strong {
  font-size: clamp(1.2em, 3vw, 1.6em);
  font-weight: 800;

  color: #e5e7eb;
  transform: translateY(-0%);
  font-size: 50px;
}

/* ======================================================
   MODULES PANEL
====================================================== */

#modules-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 200px);
}

.modules-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

/* ======================================================
   MODULE BUTTONS
====================================================== */

.module-btn {
  background: #1e2333;
  border: 1px solid #2a2f3f;
  border-radius: 12px;
  padding: 12px;
  color: #e6e6e6;
  cursor: pointer;
  text-align: left;
  transition: background .15s ease, border .15s ease;
}

.module-btn:hover {
  background: #232a40;
}

.module-btn.active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59,130,246,.6);
}

.module-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: x-large;
}

.modules-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px; /* room for scrollbar */
}

.modules-list::-webkit-scrollbar {
  width: 8px;
}

.modules-list::-webkit-scrollbar-track {
  background: transparent;
}

.modules-list::-webkit-scrollbar-thumb {
  background-color: #374151;      /* slate-600 */
  border-radius: 999px;
  border: 2px solid transparent;  /* padding effect */
  background-clip: content-box;
}

.modules-list::-webkit-scrollbar-thumb:hover {
  background-color: #4b5563;      /* slate-500 */
}

/* Group wrapper */
.module-group {
  margin-top: 10px;
}

/* Folder header */
.module-group-header {
  width: 100%;
  background: none;
  border: none;
  color: #9ca3af;
  font-weight: 600;
  font-size: large;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 4px;
  cursor: pointer;
  display: flex;
  text-align: left;
  justify-content: flex-start;
}

/* Arrow */
.module-group-header::after {
  content: "▸";
  transition: transform 0.2s ease;
}

.module-group-header.open::after {
  transform: rotate(90deg);
}

/* Body */
.module-group-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: large;
  padding-left: 6px;
  margin-top: 4px;
}

.module-group-body.collapsed {
  display: none;
  font-size: large;
}

.module-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  font-size: large;
  border-radius: 8px;
  background: #1e2333;
  border: none;
  cursor: pointer;
  color: #e5e7eb;
}

.module-main {
  font-weight: 600;
}

.module-meta {
  display: flex;
  flex-wrap: wrap;       /* ✅ */
  gap: 6px;
  justify-content:space-between; /* ✅ */
  min-width: 0;          /* ✅ VERY IMPORTANT */
}



.module-btn.active {
  background: #064e3b;            /* emerald-900 */
  box-shadow: 0 0 0 1px #10b981;
}

.module-btn.active .module-name {
  color: #d1fae5;
}

.module-btn.active .module-meta {
  color: #a7f3d0;
}

.module-meta .streak.current {
  color: #22c55e; /* green */
  font-weight: 600;
}

.module-meta .streak.best {
  color: #f59e0b; /* amber */

}

.module-btn.active .module-desc {
  color: #86efac;
}

/* Description (Weakest Cards) */
.module-desc {
  font-size: large;
  font-weight: 400;
  color: #9ca3af;
}

.module-btn,
.module-main,
.module-meta {
  min-width: 0;
}

.modules-list {
  overflow-x: hidden; /* ✅ */
}

.content-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 20px;
  border-radius: 50px;
  background: #064e3b;
  border: 1px solid #5bb37b;
  color: #e5e7eb;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border .15s ease;
}

.content-toggle:hover {
  background: rgb(9, 121, 93);
}

.toggle-icon {
  font-size: 1.1em;
  opacity: 0.85;
}

.toggle-label {
  flex: 1;
  text-align: left;
}







/* ======================================================
   BOTTOM BAR
====================================================== */

.bottom-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #161a22;
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  justify-content: center;
  gap: 14px;
  height: 75px;
  width: min(420px, 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
  visibility: hidden;
}

.bottom-bar button {
  background: none;
  border: none;
  font-size: 1.2em;
  color: #9ca3af;
  cursor: pointer;
}

.bottom-bar button:hover {
  color: #e5e7eb;
}

#nav-ranked:disabled {
  display: none;
}


/* ======================================================
   LIGHT MODE
====================================================== */

body.light {
  background: #f5f5f5;
  color: #111827;
}

body.light .top-bar,
body.light .bottom-bar,
body.light .app,
body.light .casual-panel,
body.light .ranked-panel {
  background: #ffffff;
}

body.light .card-face {
  background: #f1f5f9;
  color: #111827;
}

body.light input {
  background: #e5e7eb;
  color: #111827;
}

body.light .bottom-bar button {
  color: #111827;
}

#casual-input {
  min-height: 100px;
  text-align: center;
  font-size: x-large;
}

/* ======================================================
   TTS CONTROL – LABEL + SLIDER REDESIGN
====================================================== */

.tts-control {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #1e2333;
  font-size: x-large;
}

/* Label styling */
.tts-control label {
  font-size: 0.75em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
  font-weight: 600;
  font-size: x-large;
  user-select: none;
}

/* ===== Range base ===== */

.tts-control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(to right,
      #3b82f6 0%,
      #3b82f6 60%,
      #374151 60%,
      #374151 100%);
  outline: none;
  cursor: pointer;
}

/* ===== WebKit (Chrome, Safari, Mobile) ===== */

.tts-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  transform: translateY(-6px);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e5e7eb;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .4);
  transition: transform .15s ease, box-shadow .15s ease;
}


/* ===== Firefox ===== */

.tts-control input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #374151;
}

.tts-control input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: #3b82f6;
}

.tts-control input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e5e7eb;
  border: none;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .4);
}

.tts-control input[type="range"]::-webkit-slider-runnable-track {
  height: 12px;
  background: #374151;
  border-radius: 999px;
}

.tts-control input[type="range"]::-moz-range-track {
  height: 36px;
  background: transparent;
  border-radius: 999px;
}

/* ===== Mobile touch target ===== */

/* ===============================
   VIEWPORT SCALING (MOBILE ONLY)
=============================== */

#viewport-scale {
  width: 100%;
  height: auto;
}

/* Only apply scaling on small screens */
/* ===============================
   MOBILE STACKED LAYOUT
=============================== */
/* ===============================
   MOBILE: WIDTH ANCHORED TO GAME
=============================== */
@media (max-width: 1080px) {
  .layout {
    display: flex;
    flex-direction: column;
    gap: 16px;

    width: 520px;
    max-width: 100%;
  }

  .app,
  .casual-panel,
  .ranked-panel {
    width: 100%;
  }

  .app { order: 1; }
  .ranked-panel { order: 2; }
  .casual-panel { order: 3; }
}


