/* ---------- Practice page layout ---------- */

.practice-layout {
  display: flex;
  gap: 0;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-height: 560px;
  border: 1px solid var(--grid-line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  align-items: stretch;
}

.practice-layout.reversed { flex-direction: row-reverse; }

.formula-list-panel {
  width: 260px;
  flex-shrink: 0;
  min-height: 0;
  max-height: 860px;
  border-right: 1px solid var(--grid-line);
  background: var(--paper);
  display: flex;
  flex-direction: column;
}

.practice-layout.reversed .formula-list-panel {
  border-right: none;
  border-left: 1px solid var(--grid-line);
}

.formula-list-header {
  padding: 16px;
  border-bottom: 1px solid var(--grid-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.formula-list-header h3 {
  font-size: 13px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.swap-btn {
  background: none;
  border: 1px solid var(--grid-line);
  border-radius: var(--radius);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--ink-soft);
}
.swap-btn:hover { border-color: var(--ink); color: var(--ink); }

.formula-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.formula-list-item {
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.formula-video-icon {
  font-size: 14px;
  text-decoration: none;
  opacity: 1;
  filter: none;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.formula-video-icon:hover { transform: scale(1.2); }
.formula-video-icon.faded {
  opacity: 0.25;
  filter: grayscale(1);
  cursor: default;
}
.formula-video-icon.faded:hover { transform: none; }

.formula-list-item:hover { background: #F0F5F1; transform: translateX(3px) scale(1.015); box-shadow: 0 4px 10px rgba(28,35,33,0.08); }

.formula-list-category {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--excel-green-deep);
  padding: 16px 12px 8px;
  border-bottom: 1px solid var(--grid-line);
  margin-bottom: 4px;
}
.formula-list-category:first-child { padding-top: 2px; }

.practice-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  margin-left: 4px;
  vertical-align: middle;
}

.practice-quicklinks {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.practice-quicklinks a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 20px;
  background: var(--excel-green);
  border: 1px solid var(--excel-green);
  color: #fff;
  text-decoration: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(28,107,65,0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.practice-quicklinks a:hover {
  transform: translateY(-2px);
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 8px 18px rgba(201,151,30,0.3);
}

.task-chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.task-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--grid-line);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.task-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(28,35,33,0.1);
}
.task-chip.selected {
  background: var(--excel-green);
  color: #fff;
  border-color: var(--excel-green);
}

.nav-quicklinks-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-quicklinks-strip a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 16px;
  background: var(--excel-green);
  color: #fff;
  text-decoration: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(28,107,65,0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.nav-quicklinks-strip a:hover {
  transform: translateY(-2px);
  background: var(--amber);
  box-shadow: 0 5px 12px rgba(201,151,30,0.3);
}

.about-excel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px;
  padding: 14px;
  background: linear-gradient(135deg, var(--excel-green), var(--excel-green-deep));
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(28,107,65,0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.about-excel-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(28,107,65,0.35);
}

.formula-list-item.selected {
  background: var(--excel-green);
  color: #fff;
}

.formula-list-item .flname {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 400;
  font-size: 14px;
}

.practice-main {
  flex: 1;
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.practice-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 320px;
}

.practice-active { width: 100%; }

.practice-active h2 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--excel-green-deep);
}

.practice-active .target-label {
  font-size: 15px;
  color: var(--ink-soft);
  margin: 0 0 16px;
}

/* ---------- Modal ---------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 35, 33, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: #F0F5F1;
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  z-index: 2;
}
.modal-close-btn:hover {
  background: var(--excel-green);
  color: #fff;
}

.modal-box .formula-title {
  margin-bottom: 8px;
}

.modal-box .formula-category {
  margin-bottom: 20px;
}

.modal-box h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin: 18px 0 8px;
}

.modal-box p {
  font-size: 14px;
  color: var(--ink);
  margin: 0;
  line-height: 1.6;
}

.modal-box .params-table { margin-top: 4px; }

.modal-ready-btn {
  width: 100%;
  margin-top: 24px;
}

/* ---------- Celebration feedback ---------- */

.celebrate {
  color: var(--excel-green-deep);
  font-weight: 600;
}

/* ---------- Richer modal styling ---------- */

.modal-box {
  border-top: 5px solid var(--excel-green);
  box-shadow: 0 20px 50px rgba(28,35,33,0.25);
}

.modal-box .formula-title {
  font-size: 20px;
  background: #F0F5F1;
  border-color: var(--excel-green);
}

.modal-box h4 {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--excel-green-deep);
  font-size: 12px;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--grid-line);
  padding-bottom: 6px;
}

.modal-box .params-table th {
  background: #F0F5F1;
}

.modal-ready-btn {
  font-size: 15px;
  padding: 14px;
}

/* ---------- Result popup ---------- */

#resultBox {
  border-top-width: 5px;
}

#resultBox.result-success { border-top-color: var(--excel-green); }
#resultBox.result-fail { border-top-color: var(--amber); }

.result-icon {
  font-size: 44px;
  margin-bottom: 6px;
}

.result-message {
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 22px;
}

.result-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.result-btn-row .btn { flex: 1; min-width: 120px; }

/* ---------- Formula reference cards ---------- */

.formula-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.formula-card {
  display: block;
  background: #fff;
  border: 1px solid var(--grid-line);
  border-top: 4px solid var(--excel-green);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.formula-card:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 16px 30px rgba(28,35,33,0.16);
  z-index: 2;
  position: relative;
}

.formula-card-name {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 18px;
  color: var(--excel-green-deep);
  margin-bottom: 8px;
}

.formula-card-desc {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 14px;
  line-height: 1.5;
}

.formula-card-cta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--amber);
  font-weight: 600;
}

/* ---------- Icon result buttons with hover tooltip ---------- */

.icon-btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.icon-btn {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--grid-line);
  background: #fff;
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover { background: #F0F5F1; border-color: var(--excel-green); }
.icon-btn.primary { background: var(--excel-green); border-color: var(--excel-green); color: #fff; }
.icon-btn.primary:hover { background: var(--excel-green-deep); }

.question-progress {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--amber);
  margin-bottom: 4px;
  display: block;
}

/* ---------- Sheet overlay/z-index fix ---------- */

#luckysheetContainer {
  isolation: isolate;
  z-index: 1;
}

/* ---------- Hero animation ---------- */

.formula-bar .content.typing {
  border-right: 2px solid var(--excel-green);
  white-space: nowrap;
  overflow: hidden;
  animation: none;
}

@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.hero-float {
  animation: heroFloat 3.5s ease-in-out infinite;
}

/* ---------- Real spreadsheet-style formula bar ---------- */

.formula-toolbar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--grid-line);
  background: #fff;
}

.cellref-box {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--excel-green-deep);
  padding: 9px 14px;
  border-right: 1px solid var(--grid-line);
  background: #F0F5F1;
  min-width: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fx-icon {
  font-family: 'IBM Plex Mono', monospace;
  font-style: italic;
  color: var(--excel-green);
  padding: 9px 10px;
  border-right: 1px solid var(--grid-line);
  display: flex;
  align-items: center;
  font-size: 13px;
}

.formula-bar-input {
  flex: 1;
  border: none;
  padding: 9px 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  outline: none;
}

.formula-bar-input:disabled { background: #FAFAF7; color: var(--ink-soft); }

/* ---------- Autocomplete-style suggestion box ---------- */

.formula-suggest {
  display: none;
  border-bottom: 1px solid var(--grid-line);
  background: #FCFCF9;
  padding: 12px 16px;
  font-size: 13px;
}

.formula-suggest .suggest-syntax {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  color: var(--excel-green-deep);
  margin-bottom: 6px;
}

.formula-suggest .suggest-desc {
  color: var(--ink-soft);
  margin-bottom: 8px;
  line-height: 1.5;
}

.formula-suggest .suggest-param {
  padding: 4px 0;
  border-top: 1px solid var(--grid-line);
  font-size: 12px;
  color: var(--ink);
}

.formula-suggest .suggest-param strong {
  color: var(--excel-green-deep);
  font-family: 'IBM Plex Mono', monospace;
}

/* ---------- Full-size grid ---------- */

.grid-scroll {
  overflow: auto;
  max-height: 380px;
}

.practice-table {
  min-width: 100%;
}

.practice-table td, .practice-table th {
  min-width: 84px;
  height: 30px;
}

.practice-table td.colhead, .practice-table th.colhead {
  min-width: 30px;
  width: 30px;
  position: sticky;
  left: 0;
  background: #FAFAF7;
  z-index: 2;
}

.practice-table tr:first-child .colhead {
  position: sticky;
  top: 0;
  z-index: 3;
}

.practice-table .blank-cell {
  color: var(--grid-line);
}

.practice-table td.target-cell {
  background: #FFF6C9;
  border: 2px solid var(--amber);
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Formula filter buttons + practiced-formula highlight ---------- */

.formula-filter-btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid var(--grid-line);
  background: #fff;
  color: var(--ink-soft);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.formula-filter-btn.active {
  background: var(--excel-green);
  color: #fff;
  border-color: var(--excel-green);
}

.formula-list-item.practiced .flname {
  color: #2563EB;
}

/* ---------- Clickable active formula title (re-opens the info popup) ---------- */

#activeTitle.clickable-title {
  cursor: pointer;
}
#activeTitle .active-title-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 3;
}
#activeTitle.clickable-title:hover .active-title-tip {
  opacity: 1;
}

/* ---------- Back-to-Interview-Prep icon (isolated practical question mode) ---------- */

.back-to-interview-btn {
  position: relative;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--excel-green);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}
.back-to-interview-btn:hover {
  background: var(--coral, #C96F4A);
  transform: scale(1.08);
}
.back-to-interview-tip {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  background: #1C1C1C;
  color: #FFFFFF;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  padding: 6px 11px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  z-index: 999;
}
.back-to-interview-btn:hover .back-to-interview-tip { opacity: 1; }

/* ---------- Isolated interview-question mode: no sidebar needed ---------- */
/* When arriving via a specific Interview Prep question link, the formula
   list sidebar is skipped entirely (not loaded, not rendered) — this hides
   its space and lets the spreadsheet use the full width, so it reads like
   a dedicated page even though it's the same practice.html underneath. */
.practice-layout.isolated-question .formula-list-panel { display: none; }
.practice-layout.isolated-question .swap-btn { display: none; }
