/* ==========================================================================
   OCP Java 17 Prep — Content Elements (Tables, Code Blocks, Syntax, Traps)
   ========================================================================== */

/* Tables */
.note-content table,
table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.88rem;
}

th, td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-elevated);
  color: var(--text);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Code Blocks */
code:not(.code code) {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--primary);
}

.code-block {
  position: relative;
  margin: 14px 0;
}

.code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.55;
  overflow: auto;
  color: var(--code-text);
  margin: 0;
  counter-reset: line;
}

.code-line {
  display: block;
  min-height: 1.55em;
  padding-left: 2.8em;
  position: relative;
}

.code-line::before {
  counter-increment: line;
  content: counter(line);
  color: var(--muted);
  opacity: 0.45;
  position: absolute;
  left: 0;
  width: 2em;
  text-align: right;
  user-select: none;
  border-right: 1px solid var(--code-border);
  padding-right: 0.6em;
}

/* Java syntax palette */
.tok-keyword { color: #c792ea; }
.tok-type { color: #82aaff; }
.tok-string { color: #c3e88d; }
.tok-number { color: #f78c6c; }
.tok-comment { color: #69768c; font-style: italic; }
.tok-annotation { color: #ffcb6b; }

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 2;
}

.copy-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--primary);
}

.copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

.copy-btn .check-icon {
  display: none;
}
.copy-btn.copied .copy-icon {
  display: none;
}
.copy-btn.copied .check-icon {
  display: inline-block;
}

/* Code traps */
.trap-list {
  display: grid;
  gap: 14px;
}

.reveal-answer {
  border-top: 1px solid var(--border-subtle);
  margin-top: 12px;
  padding-top: 12px;
}

/* Checklist */
.checklist {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.checklist label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}

.checklist label:last-child {
  border-bottom: 0;
}

.checklist input {
  width: 1.05em;
  height: 1.05em;
  translate: 0 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checklist label:has(input:checked) {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
  text-decoration-thickness: 1px;
}

/* Wide tables (coverage matrix) */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 14px 0;
}

.table-wrap table {
  margin: 0;
}

.coverage {
  min-width: 900px;
}

.coverage .uncovered td {
  background: var(--danger-soft);
}

.print-button {
  float: right;
  margin-bottom: 12px;
}

/* Table headers are uppercased; keep code identifiers in their real case */
th code {
  text-transform: none;
  letter-spacing: 0;
}

/* Lists and quotes inside rendered markdown */
.note-content ul,
.note-content ol,
.explanation ul,
.explanation ol {
  margin: 0 0 12px;
  padding-left: 1.4em;
}

.note-content li,
.explanation li {
  margin: 4px 0;
}

.note-content li > ul,
.note-content li > ol {
  margin: 4px 0 4px;
}

blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--primary);
  background: var(--surface-elevated);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
}

/* Read state for notes */
.note.is-read {
  border-left: 3px solid var(--success);
}

.mark-note.is-read {
  color: var(--success);
  border-color: var(--success);
}

/* Long section lists must scroll instead of running off-screen */
.toc {
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

/* Tall dialogs scroll on short screens */
dialog {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

/* The header wraps onto several rows on narrow screens */
@media (max-width: 960px) {
  html {
    scroll-padding-top: 130px;
  }
}

/* Larger tap targets on touch devices */
@media (pointer: coarse) {
  .small-button {
    min-height: 36px;
  }
  .toc a {
    padding: 9px 10px;
  }
}
