/* ============================================================
   ASCII Table — "Digital Codex" Theme
   CRT phosphor meets editorial luxury
   ============================================================ */

:root {
  /* Phosphor palette */
  --green-50:  #e0fff0;
  --green-100: #b0ffd6;
  --green-200: #66ffaa;
  --green-300: #00ff88;
  --green-400: #00ff41;
  --green-500: #00e639;
  --green-600: #00b82e;
  --green-700: #008a22;
  --green-800: #005c17;
  --green-900: #003d0f;

  /* Amber accent */
  --amber-400: #ffbe0b;
  --amber-500: #fb8500;

  /* Surface palette — layered darks */
  --surface-0:   #050505;
  --surface-1:   #0a0a0a;
  --surface-2:   #111111;
  --surface-3:   #181818;
  --surface-4:   #222222;
  --surface-5:   #2a2a2a;

  /* Text */
  --text-primary:    #e8e8e8;
  --text-secondary:  #888888;
  --text-muted:      #555555;
  --text-glow:       var(--green-400);

  /* Borders */
  --border-subtle:   rgba(255,255,255,0.06);
  --border-medium:   rgba(255,255,255,0.1);

  /* Sizing */
  --header-h: 64px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --glow-sm: 0 0 6px rgba(0,255,65,0.15);
  --glow-md: 0 0 20px rgba(0,255,65,0.12);
  --glow-lg: 0 0 40px rgba(0,255,65,0.1);
  --shadow-float: 0 8px 32px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4);

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Instrument Sans', -apple-system, sans-serif;
  background: var(--surface-0);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

/* Scanlines */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
}

::selection {
  background: var(--green-400);
  color: var(--surface-0);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface-1); }
::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--surface-5); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 50% 45%, rgba(0,255,65,0.06) 0%, transparent 70%),
    var(--surface-0);
}

/* Floating glyphs behind the title */
.hero__grid {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  opacity: 0;
  animation: heroGridIn 1.8s var(--ease-out) 0.2s forwards;
}

.hero__glyph {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(6rem, 14vw, 14rem);
  font-weight: 700;
  color: var(--green-400);
  opacity: 0.04;
  text-shadow: 0 0 60px rgba(0,255,65,0.1);
  user-select: none;
  line-height: 1;
}

@keyframes heroGridIn {
  to { opacity: 1; }
}

.hero__content {
  position: relative;
  z-index: 1;
  max-width: 680px;
}

.hero__eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--green-400);
  margin-bottom: 1.25rem;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeUp 0.8s var(--ease-out) 0.5s forwards;
}

.hero__title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(3.5rem, 10vw, 8rem);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-shadow: 0 0 80px rgba(0,255,65,0.15);
  margin-bottom: 1.25rem;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 1s var(--ease-out) 0.7s forwards;
}

.hero__sub {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.7;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeUp 0.8s var(--ease-out) 0.9s forwards;
}

.hero__scroll-cue {
  position: absolute;
  bottom: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out) 1.4s forwards;
}
.hero__scroll-cue svg {
  animation: bounceDown 2s ease-in-out infinite;
}

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bounceDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* ============================================================
   TOOLBAR — Sticky search + filters
   ============================================================ */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(5,5,5,0.85);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
}

.toolbar__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Search box */
.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 520px;
}

.search-box__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
}

.search-box__input {
  width: 100%;
  padding: 0.65rem 3rem 0.65rem 2.8rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.search-box__input::placeholder {
  color: var(--text-muted);
}
.search-box__input:focus {
  border-color: var(--green-400);
  box-shadow: var(--glow-sm);
  background: var(--surface-3);
}
.search-box__input:focus ~ .search-box__icon {
  color: var(--green-400);
}
.search-box__input:focus ~ .search-box__shortcut {
  opacity: 0;
}

.search-box__shortcut {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--surface-4);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  pointer-events: none;
  transition: opacity 0.2s;
}

/* Filter buttons */
.toolbar__filters {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.filter-btn__count {
  font-size: 0.62rem;
  opacity: 0.5;
}

.filter-btn:hover {
  border-color: var(--green-400);
  color: var(--green-400);
  background: rgba(0,255,65,0.04);
}

.filter-btn.active {
  background: var(--green-400);
  color: var(--surface-0);
  border-color: var(--green-400);
  box-shadow: var(--glow-sm);
}
.filter-btn.active .filter-btn__count {
  opacity: 0.7;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
}

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
}

.ascii-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  table-layout: fixed;
}

/* Column widths */
.col-dec  { width: 70px; }
.col-oct  { width: 70px; }
.col-hex  { width: 70px; }
.col-bin  { width: 100px; }
.col-sym  { width: 90px; }
.col-html { width: 100px; }
.col-entity { width: 120px; }
.col-desc { width: auto; }

.ascii-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.ascii-table th {
  padding: 0.75rem 0.85rem;
  text-align: left;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--green-400);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-medium);
  white-space: nowrap;
  user-select: none;
}

.ascii-table th[data-sort] {
  cursor: pointer;
}
.ascii-table th[data-sort]:hover {
  color: var(--green-200);
}

.sort-arrow {
  font-size: 0.6rem;
  margin-left: 0.25rem;
}
.sort-arrow::after {
  content: '\25B2'; /* up arrow */
  opacity: 0.3;
}
th.sort-asc .sort-arrow::after { opacity: 1; content: '\25B2'; }
th.sort-desc .sort-arrow::after { opacity: 1; content: '\25BC'; }

.ascii-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
  transition: background 0.15s;
}

.ascii-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.ascii-table tbody tr:hover {
  background: rgba(0,255,65,0.03);
}
.ascii-table tbody tr:hover td {
  border-bottom-color: rgba(0,255,65,0.08);
}

/* Category group headers */
.ascii-table .group-header td {
  padding: 1.1rem 0.85rem 0.6rem;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--green-400);
  background: var(--surface-0);
  border-bottom: 1px solid var(--border-medium);
  cursor: default;
}
.group-header:hover {
  background: var(--surface-0) !important;
}

/* Symbol cell */
.cell-sym {
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  color: var(--green-300);
  text-shadow: 0 0 8px rgba(0,255,65,0.2);
  min-width: 2rem;
}

/* Control character badge */
.cell-sym--ctrl {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--amber-400);
  background: rgba(255,190,11,0.08);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  display: inline-block;
  text-shadow: none;
}

/* Copyable cells */
.copyable {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.copyable:hover {
  background: rgba(0,255,65,0.08);
  color: var(--green-300);
}
.copyable::after {
  content: '';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='9' y='9' width='11' height='11' rx='2' stroke='%2300ff41' stroke-width='2'/%3E%3Cpath d='M5 15V5a2 2 0 012-2h10' stroke='%2300ff41' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
  opacity: 0;
  transition: all 0.2s var(--ease-spring);
}
.copyable:hover::after {
  opacity: 0.6;
  transform: translateY(-50%) scale(1);
}

/* Description column */
.cell-desc {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Muted values (like empty entity) */
.cell-muted {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.75rem;
}

/* Row animation on first load */
.ascii-table tbody tr {
  opacity: 0;
  transform: translateY(4px);
  animation: rowIn 0.3s var(--ease-out) forwards;
}

@keyframes rowIn {
  to { opacity: 1; transform: translateY(0); }
}

/* No results */
.no-results {
  display: none;
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
}
.no-results.visible {
  display: block;
}
.no-results__icon {
  font-family: 'DM Serif Display', serif;
  font-size: 4rem;
  color: var(--green-400);
  opacity: 0.3;
  margin-bottom: 1rem;
  text-shadow: var(--glow-md);
}
.no-results__hint {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* ============================================================
   MODAL — Character Detail
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-float), var(--glow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.35s var(--ease-spring);
}
.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface-4);
  color: var(--text-secondary);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}
.modal__close:hover {
  background: var(--green-400);
  color: var(--surface-0);
}

.modal__symbol {
  font-family: 'JetBrains Mono', monospace;
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--green-400);
  text-shadow: var(--glow-md);
  margin-bottom: 0.5rem;
  line-height: 1;
}
.modal__symbol--ctrl {
  font-size: 1.8rem;
  color: var(--amber-400);
  background: rgba(255,190,11,0.08);
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  text-shadow: none;
}

.modal__name {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.modal__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.modal__field {
  background: var(--surface-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.modal__field:hover {
  border-color: var(--green-400);
  background: rgba(0,255,65,0.04);
}
.modal__field:active {
  transform: scale(0.97);
}

.modal__field-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.modal__field-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.modal__desc {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--surface-0);
  background: var(--green-400);
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--glow-md), 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s var(--ease-spring);
  z-index: 2000;
}
.toast.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  border-top: 1px solid var(--border-subtle);
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.footer__brand {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.footer__note {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
}
.footer__note kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  background: var(--surface-3);
  border: 1px solid var(--border-subtle);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .col-bin { display: none; }
  .ascii-table td:nth-child(4) { display: none; }
  .col-entity { display: none; }
  .ascii-table td:nth-child(7) { display: none; }
}

@media (max-width: 768px) {
  .hero__glyph { font-size: clamp(4rem, 12vw, 8rem); }
  .hero { min-height: 85vh; }

  .toolbar__inner {
    flex-direction: column;
    gap: 0.6rem;
  }
  .search-box { max-width: 100%; }

  .col-oct { display: none; }
  .ascii-table td:nth-child(2) { display: none; }
  .col-html { display: none; }
  .ascii-table td:nth-child(6) { display: none; }

  .ascii-table {
    font-size: 0.75rem;
    table-layout: auto;
  }
  .ascii-table th,
  .ascii-table td {
    padding: 0.5rem 0.6rem;
  }

  .modal { padding: 1.8rem; }
  .modal__symbol { font-size: 2.5rem; }
  .modal__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .hero__title { font-size: 3rem; }

  .toolbar__filters { gap: 0.25rem; }
  .filter-btn {
    font-size: 0.65rem;
    padding: 0.35rem 0.65rem;
  }

  .col-hex { display: none; }
  .ascii-table td:nth-child(3) { display: none; }

  .modal__grid { grid-template-columns: 1fr; }
}

/* ============================================================
   UTILITY
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}
