/* Styles for the Storage Foundations page (bits, bytes, offsets, clusters, and exercises) */

.foundations-hero {
  background: var(--term-bg);
  color: var(--term-fg);
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border);
}
.foundations-hero .wrap {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}
.hero-nav-links {
  display: flex;
  gap: 10px;
  align-items: center;
}
.hero-nav-links .btn-ghost {
  border: 1px solid #444a53;
  color: #c5c9cf;
  background: transparent;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: .88rem;
}
.hero-nav-links .btn-ghost:hover {
  background: #23262b;
  color: #fff;
  border-color: #6a737d;
}

/* Card & Widget Layouts */
.concept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  box-shadow: 0 2px 8px rgb(0 0 0 / .04);
}
.concept-card h3 {
  margin-top: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Bit visualizer / 8-bit register */
.bit-register {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}
.bits-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  max-width: 560px;
}
.bit-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 4px;
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
  transition: all .15s ease;
}
.bit-box:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.bit-box.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 10px rgb(179 38 30 / .3);
}
.bit-idx {
  font-size: .72rem;
  font-family: var(--mono);
  opacity: .75;
}
.bit-val {
  font-size: 1.4rem;
  font-family: var(--mono);
  font-weight: 700;
  line-height: 1.2;
}
.bit-weight {
  font-size: .75rem;
  font-family: var(--mono);
  font-weight: 600;
  opacity: .85;
}

.converter-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.conv-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.conv-group label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .05em;
}
.conv-group input {
  font-family: var(--mono);
  font-size: 1.05rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.conv-group input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

/* Endianness Visualizer */
.endian-demo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 16px 0;
}
@media (max-width: 720px) {
  .endian-demo {
    grid-template-columns: 1fr;
  }
}
.endian-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.endian-box h4 {
  margin: 0 0 10px;
  font-size: .95rem;
}
.byte-row {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}
.byte-cell {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  padding: 8px 4px;
  font-family: var(--mono);
}
.byte-cell .cell-addr {
  font-size: .7rem;
  color: var(--muted);
  display: block;
}
.byte-cell .cell-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}
.byte-cell .cell-signif {
  font-size: .68rem;
  color: var(--muted);
  display: block;
}

/* Hex Grid Explorer */
.hex-explorer-wrap {
  overflow-x: auto;
  margin: 16px 0;
  background: var(--term-bg);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--term-fg);
  font-family: var(--mono);
  font-size: .88rem;
}
.hex-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 680px;
}
.hex-table th {
  padding: 4px 6px;
  color: var(--term-prompt);
  font-size: .78rem;
  text-align: center;
  border-bottom: 1px solid #333842;
}
.hex-table th.th-off {
  text-align: left;
}
.hex-table td {
  padding: 4px 5px;
  text-align: center;
}
.hex-table td.td-off {
  text-align: left;
  color: var(--term-dim);
  font-weight: 600;
}
.hex-table td.td-ascii {
  text-align: left;
  letter-spacing: .1em;
  color: #98c379;
  border-left: 1px solid #333842;
  padding-left: 10px;
}
.hex-byte {
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
  transition: all .1s ease;
}
.hex-byte:hover {
  background: #3e4451;
  color: #fff;
}
.hex-byte.selected {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.hex-inspector-panel {
  margin-top: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  font-size: .9rem;
}
.inspect-item strong {
  display: block;
  font-size: .75rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.inspect-item span {
  font-family: var(--mono);
  font-weight: 600;
}

/* Disk Layout Visualizer */
.disk-visualizer {
  margin: 20px 0;
}
.disk-bar {
  display: flex;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 12px 0;
  box-shadow: inset 0 2px 4px rgb(0 0 0 / .08);
}
.disk-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  padding: 0 4px;
  cursor: pointer;
  transition: opacity .15s ease, filter .15s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.disk-segment:hover {
  filter: brightness(1.15);
}
.seg-mbr { background: #5c6370; }
.seg-unpart { background: #3b4048; }
.seg-res { background: #d19a66; }
.seg-fat1 { background: #4b88c4; }
.seg-fat2 { background: #2f6599; }
.seg-data { background: #398e57; }
.seg-slack { background: #964f4c; }

.disk-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: .84rem;
  margin-top: 8px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.calc-params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.calc-fld {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calc-fld label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
}
.calc-fld input {
  font-family: var(--mono);
  font-size: .95rem;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.calc-result-box {
  background: var(--surface-2);
  border-left: 4px solid var(--ok);
  border-radius: 6px;
  padding: 14px 18px;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: .92rem;
}
.calc-result-box .step {
  margin: 6px 0;
}

/* Exercises Section */
.exercise-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  transition: border-color .2s ease;
}
.exercise-card.completed {
  border-color: var(--ok);
  background: linear-gradient(to bottom, var(--ok-soft) 0%, var(--surface) 20%);
}
.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.exercise-title {
  margin: 0;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.exercise-badge {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
}
.exercise-badge.done {
  background: var(--ok-soft);
  color: var(--ok);
}
.question-prompt {
  font-size: 1rem;
  margin: 12px 0 16px;
  line-height: 1.5;
}
.exercise-interactive {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 16px;
  margin: 14px 0;
}
.exercise-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.exercise-row input[type="text"] {
  font-family: var(--mono);
  font-size: 1rem;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-width: 140px;
}
.exercise-row input[type="text"]:focus {
  outline: 2px solid var(--accent);
}
.exercise-feedback {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: .9rem;
  display: none;
}
.exercise-feedback.show {
  display: block;
}
.exercise-feedback.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid var(--ok);
}
.exercise-feedback.err {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.exercise-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}
.btn-sm {
  font-size: .85rem;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
}
.solution-box {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: .9rem;
  display: none;
}
.solution-box.show {
  display: block;
}

/* Progress Tracker */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.progress-meter {
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress-meter progress {
  width: 180px;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
}

/* Key formulas highlight */
.formula-block {
  background: var(--term-bg);
  color: var(--term-fg);
  border-radius: 8px;
  padding: 14px 18px;
  font-family: var(--mono);
  font-size: .95rem;
  margin: 14px 0;
  border-left: 4px solid var(--term-prompt);
  overflow-x: auto;
}
.formula-block .comment {
  color: var(--term-dim);
}
.formula-block .highlight {
  color: var(--term-warn);
  font-weight: 700;
}
