/* ============================================================
   ports.madworx.ca — Network Port Reference Tool
   CSS matching vlsm.madworx.ca design system
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- CSS Variables (Dark Default) --- */
:root {
  --bg: #000000;
  --bg-section: #0a0a0a;
  --bg-card: rgba(255,255,255,.04);
  --bg-card-hover: rgba(255,255,255,.07);
  --bg-input: rgba(255,255,255,.06);
  --text-primary: #f5f5f7;
  --text-secondary: rgba(245,245,247,.7);
  --text-tertiary: rgba(245,245,247,.45);
  --text-quaternary: rgba(245,245,247,.25);
  --border: rgba(255,255,255,.08);
  --border-focus: rgba(221,194,37,.5);
  --brand: #DDC225;
  --brand-dim: rgba(221,194,37,.15);
  --brand-glow: rgba(221,194,37,.08);
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff453a;
  --info: #64d2ff;
  --header-bg: rgba(0,0,0,.72);
  --code-bg: rgba(255,255,255,.06);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}

/* --- Light Mode --- */
:root.light {
  --bg: #fbfbfd;
  --bg-section: #f5f5f7;
  --bg-card: rgba(0,0,0,.03);
  --bg-card-hover: rgba(0,0,0,.06);
  --bg-input: rgba(0,0,0,.04);
  --text-primary: #1d1d1f;
  --text-secondary: rgba(0,0,0,.6);
  --text-tertiary: rgba(0,0,0,.4);
  --text-quaternary: rgba(0,0,0,.2);
  --border: rgba(0,0,0,.1);
  --border-focus: rgba(180,155,20,.5);
  --brand: #b49b14;
  --brand-dim: rgba(180,155,20,.1);
  --brand-glow: rgba(180,155,20,.05);
  --header-bg: rgba(251,251,253,.72);
  --code-bg: rgba(0,0,0,.04);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 80px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--text-primary); }

img { display: block; max-width: 100%; }

button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }

input { font-family: inherit; }

/* --- Custom Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--text-quaternary);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--text-quaternary) transparent;
}

/* --- Container --- */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Site Header --- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-decoration: none;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.nav { display: flex; align-items: center; gap: 4px; }

.nav a {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 980px;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav a:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 980px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: var(--text-secondary);
  transition: fill var(--transition);
}

.theme-toggle:hover svg { fill: var(--brand); }

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root.light .theme-toggle .icon-sun { display: block; }
:root.light .theme-toggle .icon-moon { display: none; }

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  border-radius: 980px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  gap: 4px;
  transition: all var(--transition);
}

.hamburger:hover {
  background: var(--bg-card-hover);
}

.hamburger span {
  display: block;
  width: 14px;
  height: 1.5px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: all var(--transition);
}

/* --- Mobile Nav --- */
.mobile-nav {
  display: none;
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 999;
  padding: 24px;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.mobile-nav.open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.mobile-nav a {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: color var(--transition), background var(--transition);
}

.mobile-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* --- Hero --- */
.hero {
  position: relative;
  padding: 140px 0 80px;
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse at center, var(--brand-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero .container { position: relative; z-index: 1; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand);
  background: var(--brand-dim);
  border: 1px solid rgba(221,194,37,.2);
  border-radius: 980px;
  margin-bottom: 24px;
}

.hero-badge svg {
  width: 14px;
  height: 14px;
}

.hero h1 {
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 20px;
}

.hero h1 .gradient {
  background: linear-gradient(135deg, var(--brand) 0%, #f0e68c 50%, var(--brand) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-lead {
  font-size: 17px;
  font-weight: 400;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 32px;
  line-height: 1.6;
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 980px;
  transition: all var(--transition);
  white-space: nowrap;
}

.pill:hover {
  color: var(--text-primary);
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
}

.pill svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* --- Section --- */
.section {
  padding: 80px 0;
}

.section-dark {
  background: var(--bg-section);
}

.section-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.section-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

/* --- Tool Card --- */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
}

.tool-card:hover {
  border-color: rgba(255,255,255,.12);
}

:root.light .tool-card:hover {
  border-color: rgba(0,0,0,.15);
}

.tool-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.tool-card-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-card-title svg {
  width: 18px;
  height: 18px;
  fill: var(--brand);
}

.tool-card-body { padding: 24px; }

/* --- Search Input --- */
.search-wrapper {
  position: relative;
  margin-bottom: 20px;
}

.search-wrapper svg {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: var(--text-tertiary);
  pointer-events: none;
  transition: fill var(--transition);
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition);
}

.search-input::placeholder { color: var(--text-tertiary); }

.search-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
  box-shadow: 0 0 0 3px var(--brand-dim);
}

.search-input:focus + svg,
.search-input:focus ~ svg { fill: var(--brand); }

/* --- Filter Chips --- */
.filter-group {
  margin-bottom: 16px;
}

.filter-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 980px;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.chip:hover {
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.chip.active {
  color: var(--brand);
  background: var(--brand-dim);
  border-color: rgba(221,194,37,.3);
}

.chip svg {
  width: 12px;
  height: 12px;
}

/* --- Info Bar --- */
.info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.info-bar-count {
  font-weight: 500;
  color: var(--text-secondary);
}

.info-bar-count strong {
  color: var(--brand);
  font-weight: 600;
}

/* --- Port Table --- */
.port-table-wrapper {
  overflow-x: auto;
  max-height: 640px;
  overflow-y: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.port-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.port-table thead th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  background: var(--bg-section);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.port-table thead th:hover {
  color: var(--brand);
}

.port-table thead th.sort-asc::after {
  content: ' ↑';
  color: var(--brand);
}

.port-table thead th.sort-desc::after {
  content: ' ↓';
  color: var(--brand);
}

.port-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.port-table tbody tr:nth-child(even) {
  background: var(--bg-card);
}

.port-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.port-table tbody td {
  padding: 10px 16px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.port-table tbody td:first-child {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--brand);
}

.port-table tbody td:nth-child(2) {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

.port-table tbody td:nth-child(3) {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.port-table tbody td:nth-child(4) {
  white-space: normal;
  max-width: 360px;
  min-width: 200px;
}

.port-table tbody td:nth-child(5) {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.category-well-known { color: var(--info); }
.category-registered { color: var(--success); }
.category-dynamic { color: var(--warning); }

/* Protocol badge */
.protocol-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.protocol-tcp {
  color: var(--info);
  background: rgba(100,210,255,.1);
}

.protocol-udp {
  color: var(--warning);
  background: rgba(255,159,10,.1);
}

.protocol-tcp-udp {
  color: var(--success);
  background: rgba(48,209,88,.1);
}

/* --- Show More Button --- */
.show-more-wrapper {
  padding: 16px 24px;
  text-align: center;
  border-top: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 980px;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  color: #000;
  background: var(--brand);
  border: 1px solid var(--brand);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-ghost {
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
}

/* --- Categories Grid --- */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: all var(--transition);
}

.category-card:hover {
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.category-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 20px;
}

.category-card-icon.well-known {
  background: rgba(100,210,255,.1);
  color: var(--info);
}

.category-card-icon.registered {
  background: rgba(48,209,88,.1);
  color: var(--success);
}

.category-card-icon.dynamic {
  background: rgba(255,159,10,.1);
  color: var(--warning);
}

.category-card h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.category-card-range {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.category-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.category-card-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-dim);
  border-radius: 980px;
  margin-bottom: 16px;
}

.category-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-example {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all var(--transition);
}

.category-example:hover {
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.category-example .port-num {
  color: var(--brand);
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  color: #000;
  background: var(--brand);
  border-radius: 980px;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 16px rgba(221,194,37,.3);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* --- Scroll Reveal --- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Footer --- */
.site-footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-section);
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-copy {
  font-size: 13px;
  color: var(--text-tertiary);
}

.footer-copy a {
  color: var(--text-secondary);
  transition: color var(--transition);
}

.footer-copy a:hover { color: var(--brand); }

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-links a {
  font-size: 13px;
  color: var(--text-tertiary);
  transition: color var(--transition);
}

.footer-links a:hover { color: var(--brand); }

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.empty-state svg {
  width: 40px;
  height: 40px;
  fill: var(--text-quaternary);
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* --- Responsive --- */
@media (max-width: 767px) {
  .nav { display: none; }
  .hamburger { display: flex; }

  .hero {
    padding: 120px 0 60px;
  }

  .hero h1 { font-size: 32px; }

  .hero-lead { font-size: 15px; }

  .section { padding: 56px 0; }

  .section-title { font-size: 24px; }

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

  .header-inner { padding: 0 16px; }
  .container { padding: 0 16px; }

  .tool-card-header { padding: 16px; }
  .tool-card-body { padding: 16px; }

  .port-table thead th,
  .port-table tbody td {
    padding: 8px 12px;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .hero-pills { gap: 6px; }
  .pill { font-size: 11px; padding: 5px 10px; }
  .filter-chips { gap: 4px; }
  .chip { font-size: 11px; padding: 5px 10px; }
  .search-input { font-size: 16px; } /* Prevent iOS zoom */
}
