/* Frequency page styles */

.freq-header { margin: 1.5rem 0 1rem; }

.freq-banner {
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.freq-banner-icon { font-size: 2.2rem; flex-shrink: 0; }
.freq-banner h1 { font-size: 1.5rem; margin-bottom: 0.2rem; }
.freq-meta { color: rgba(255,255,255,0.6); font-size: 0.85rem; }

.freq-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.freq-controls input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  width: 100%;
}
.freq-controls input:focus { border-color: var(--accent2); }
.freq-controls input::placeholder { color: var(--muted); }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid var(--border);
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  table-layout: fixed;
  font-size: 0.9rem;
}

/* Column width allocation: # | Word | Reading | POS | Meaning | Example | Count */
thead th:nth-child(1), td:nth-child(1) { width: 40px; }
thead th:nth-child(2), td:nth-child(2) { width: 12%; }
thead th:nth-child(3), td:nth-child(3) { width: 10%; }
thead th:nth-child(4), td:nth-child(4) { width: 80px; }
thead th:nth-child(5), td:nth-child(5) { width: auto; }
thead th:nth-child(6), td:nth-child(6) { width: 20%; }
thead th:nth-child(7), td:nth-child(7) { width: 72px; text-align: right; }

thead tr { background: #0d1b35; }
thead th {
  padding: 0.65rem 0.6rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  white-space: nowrap;
}
thead th:hover { color: var(--text); }

.sort-icon { opacity: 0.4; font-size: 0.72rem; }

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.04); }

td {
  padding: 0.55rem 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-cell { color: var(--muted); font-size: 0.8rem; }

.word-cell { font-size: 1.05rem; font-weight: 500; white-space: nowrap; }
.word-cell a { color: var(--text); text-decoration: none; border-bottom: 1px dashed rgba(255,255,255,0.2); }
.word-cell a:hover { color: var(--accent2); border-bottom-color: var(--accent2); }

/* Hidden by default on desktop — shown only on mobile */
.mob-sub { display: none; }
.mob-reading { color: #aaa; font-size: 0.75rem; }
.mob-count { color: var(--accent); font-size: 0.72rem; font-weight: 700; margin-left: 0.4rem; }

.reading-cell { color: #aaa; font-size: 0.85rem; }

.pos-badge {
  display: inline-block;
  background: rgba(160, 196, 255, 0.12);
  color: var(--accent2);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.meaning-cell {
  color: #bbb;
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.example-cell {
  color: #888;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.count-cell { font-weight: 700; color: var(--accent); text-align: right; font-size: 0.88rem; white-space: nowrap; }

/* Count header alignment */
thead th:nth-child(7) { text-align: right; }

.hidden { display: none; }

/* Hide count column via JS toggle */
table.hide-count thead th:nth-child(7),
table.hide-count tbody td:nth-child(7) { display: none; }

.result-count {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.4rem 0;
  text-align: right;
}

/* ── Tablet (max 1024px) ── */
@media (max-width: 1024px) {
  /* Hide Example column to save space */
  thead th:nth-child(6),
  td:nth-child(6) { display: none; }
  /* Give meaning more room */
  thead th:nth-child(5), td:nth-child(5) { width: auto; }
}

/* ── Mobile (max 768px) ── */
@media (max-width: 768px) {
  .freq-banner { padding: 0.75rem; gap: 0.6rem; }
  .freq-banner h1 { font-size: 0.95rem; }
  .freq-banner-icon { font-size: 1.3rem; }
  .freq-meta { font-size: 0.74rem; }

  .freq-controls { gap: 0.4rem; }
  .freq-controls .btn { width: 100%; text-align: center; box-sizing: border-box; }

  .table-wrap { border-radius: 8px; }

  table { font-size: 0.76rem; word-break: break-word; }

  /* Hide: Reading(3), POS(4), Example(6) — already hidden at 1024 */
  thead th:nth-child(3), td:nth-child(3),
  thead th:nth-child(4), td:nth-child(4) { display: none; }

  /* Override fixed widths for mobile 4-col layout: # | Word | Meaning | Count */
  thead th:nth-child(1), td:nth-child(1) { width: 24px; }
  thead th:nth-child(2), td:nth-child(2) { width: 30%; }
  thead th:nth-child(5), td:nth-child(5) { width: auto; }
  thead th:nth-child(7), td:nth-child(7) { width: 38px; text-align: right; }

  table.hide-count thead th:nth-child(7),
  table.hide-count td:nth-child(7) { display: none; }

  thead th, td { padding: 0.35rem 0.3rem; overflow: hidden; }
  thead th { white-space: nowrap; }
  td { white-space: normal; }

  .mob-sub { display: block; margin-top: 0.15rem; line-height: 1.2; }
  .word-cell ruby rt { display: none; }

  .rank-cell { font-size: 0.65rem; }
  .word-cell { font-size: 0.88rem; white-space: normal; }
  .mob-reading { font-size: 0.67rem; color: #aaa; display: block; }
  .mob-count { display: none; }
  .meaning-cell { font-size: 0.74rem; line-height: 1.3; white-space: normal; }
  .count-cell { font-size: 0.72rem; padding-right: 0.2rem; }
}

/* ── Small phones (max 400px) ── */
@media (max-width: 400px) {
  thead th, td { padding: 0.3rem 0.2rem; }
  table { font-size: 0.7rem; }
  .word-cell { font-size: 0.82rem; }
  .meaning-cell { font-size: 0.68rem; }
  .mob-reading { font-size: 0.62rem; }
  thead th:nth-child(2), td:nth-child(2) { width: 25%; }
  thead th:nth-child(7), td:nth-child(7) { width: 30px; }
}
