/* ============================================
   ResultHub — Advanced Mobile + PC UI
   ============================================ */
:root {
  --rh-ink: #0f2438;
  --rh-muted: #5a6b7c;
  --rh-accent: #0d7377;
  --rh-accent-deep: #095456;
  --rh-amber: #c2410c;
  --rh-bg: #eef3f7;
  --rh-surface: #ffffff;
  --rh-line: #d5e0e8;
  --rh-ok: #047857;
  --rh-danger: #b91c1c;
  --rh-radius: 16px;
  --rh-radius-sm: 12px;
  --rh-shadow: 0 12px 32px rgba(15, 36, 56, 0.08);
  --rh-shadow-lg: 0 20px 50px rgba(15, 36, 56, 0.12);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --header-h: 64px;
  --bottom-nav-h: 68px;
  --container: 1140px;
  --touch: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--rh-ink);
  background:
    radial-gradient(900px 420px at 0% -5%, rgba(13, 115, 119, 0.14), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(194, 65, 12, 0.09), transparent 50%),
    linear-gradient(180deg, #f5f8fb 0%, var(--rh-bg) 45%, #e8eef4 100%);
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 8px);
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--rh-accent); text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--rh-accent-deep); }
button, .btn, a, input, select, textarea { min-height: auto; }
.btn, .nav-link-custom, .bottom-nav a, .menu-toggle {
  min-height: var(--touch);
  min-width: var(--touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.container-rh {
  width: min(100% - 1.5rem, var(--container));
  margin-inline: auto;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  display: flex;
  align-items: center;
  backdrop-filter: saturate(1.2) blur(14px);
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(213, 224, 232, 0.9);
  box-shadow: 0 4px 20px rgba(15, 36, 56, 0.04);
}
.site-header .inner {
  width: min(100% - 1.5rem, var(--container));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  color: var(--rh-ink);
  line-height: 1;
}
.brand span { color: var(--rh-accent); }
.brand-sub {
  display: none;
  font-size: .72rem;
  color: var(--rh-muted);
  font-weight: 600;
  letter-spacing: .02em;
}

.menu-toggle {
  width: 46px;
  height: 46px;
  border: 1px solid var(--rh-line);
  border-radius: 12px;
  background: #fff;
  padding: 0;
  flex-direction: column;
  gap: 5px;
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--rh-ink);
  border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.desktop-nav { display: none; }
.desktop-nav .nav-link-custom {
  color: var(--rh-muted);
  font-weight: 600;
  padding: .45rem .85rem;
  border-radius: 999px;
  gap: .35rem;
}
.desktop-nav .nav-link-custom:hover,
.desktop-nav .nav-link-custom.active {
  color: var(--rh-ink);
  background: rgba(13, 115, 119, 0.1);
}

/* Mobile drawer */
.mobile-drawer {
  position: fixed;
  inset: var(--header-h) 0 auto 0;
  z-index: 190;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--rh-line);
  box-shadow: var(--rh-shadow);
  transform: translateY(-120%);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s ease, opacity .28s ease;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
}
.mobile-drawer.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.mobile-drawer nav {
  padding: .75rem 1rem 1.25rem;
  display: grid;
  gap: .35rem;
}
.mobile-drawer a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  border-radius: 12px;
  color: var(--rh-ink);
  font-weight: 600;
  background: #f4f7fa;
  min-height: var(--touch);
}
.mobile-drawer a:active { background: rgba(13, 115, 119, 0.12); }
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(15, 36, 56, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }

/* ---------- Hero ---------- */
.hero { padding: 1.1rem 0 .5rem; }
.hero-panel {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(13, 115, 119, 0.97) 0%, rgba(15, 36, 56, 0.94) 70%),
    url("../images/banners/hero-pattern.svg");
  background-size: cover;
  color: #fff;
  border-radius: 22px;
  padding: 1.45rem 1.2rem 1.5rem;
  box-shadow: var(--rh-shadow-lg);
  animation: rise .55s ease both;
}
.hero-panel::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -40px;
  top: -50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}
.hero-panel h1 {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 7vw, 2.85rem);
  margin: 0 0 .55rem;
  letter-spacing: -0.03em;
  max-width: 12ch;
  position: relative;
  z-index: 1;
}
.hero-panel p {
  max-width: 38ch;
  opacity: .93;
  margin: 0 0 1.15rem;
  font-size: 1.02rem;
  position: relative;
  z-index: 1;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  position: relative;
  z-index: 1;
}

.btn-rh, .btn-rh-outline {
  border-radius: 999px;
  font-weight: 700;
  padding: .78rem 1.25rem;
  border: 0;
  text-align: center;
  transition: transform .15s ease, background .2s ease, box-shadow .2s ease;
}
.btn-rh {
  background: #fff;
  color: var(--rh-ink);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}
.btn-rh:hover { color: var(--rh-ink); transform: translateY(-1px); }
.btn-rh-outline {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.btn-rh-outline:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }

.badge-live, .badge-time {
  border-radius: 999px;
  font-weight: 700;
  font-size: .78rem;
  padding: .4rem .75rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.badge-live {
  background: rgba(255, 255, 255, 0.16);
  color: #d1fae5;
}
.badge-live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  animation: pulse 1.6s infinite;
}
.badge-time {
  background: rgba(255, 255, 255, 0.12);
  color: #ffedd5;
  font-variant-numeric: tabular-nums;
}

/* ---------- Sections ---------- */
.site-main { padding-bottom: 1rem; }
.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.5vw, 1.7rem);
  margin: 0 0 .3rem;
  letter-spacing: -0.02em;
}
.section-sub { color: var(--rh-muted); margin: 0 0 1rem; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .85rem;
}
.section-head .section-sub { margin: 0; }
.link-more {
  font-weight: 700;
  font-size: .92rem;
  white-space: nowrap;
}

.panel {
  background: var(--rh-surface);
  border: 1px solid var(--rh-line);
  border-radius: var(--rh-radius);
  box-shadow: var(--rh-shadow);
  padding: 1rem;
}
.search-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: .65rem;
  padding: .85rem;
}
.search-panel .form-control {
  min-height: var(--touch);
  border-radius: 12px;
  border-color: var(--rh-line);
  font-size: 16px; /* prevents iOS zoom */
}
.search-panel .btn {
  min-height: var(--touch);
  border-radius: 12px;
  font-weight: 700;
}

.notice {
  border-left: 4px solid var(--rh-accent);
  background: #fff;
  border-radius: 12px;
  padding: .9rem 1rem;
  margin-bottom: .7rem;
  box-shadow: 0 6px 18px rgba(15, 36, 56, 0.05);
  animation: fadein .45s ease both;
}
.notice.warning { border-left-color: var(--rh-amber); }
.notice.danger { border-left-color: var(--rh-danger); }
.notice.success { border-left-color: var(--rh-ok); }

/* ---------- Results: mobile cards / desktop table ---------- */
.result-value {
  font-weight: 800;
  color: var(--rh-ok);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.result-cards { display: grid; gap: .7rem; }
.result-card {
  background: #fff;
  border: 1px solid var(--rh-line);
  border-radius: var(--rh-radius-sm);
  padding: .95rem 1rem;
  box-shadow: 0 8px 22px rgba(15, 36, 56, 0.05);
  animation: rise .45s ease both;
  transition: transform .18s ease, box-shadow .18s ease;
}
.result-card:active { transform: scale(0.99); }
.result-card .top {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .35rem;
}
.result-card .event-name {
  font-weight: 700;
  color: var(--rh-ink);
  font-size: 1.02rem;
}
.result-card .meta {
  color: var(--rh-muted);
  font-size: .86rem;
  margin-bottom: .45rem;
}
.result-card .value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
}
.result-card .time-chip {
  background: rgba(194, 65, 12, 0.1);
  color: var(--rh-amber);
  font-weight: 700;
  font-size: .78rem;
  padding: .28rem .55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.table-desktop { display: none; }
.result-table th {
  background: #f0f6f8;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--rh-muted);
  white-space: nowrap;
}
.result-table td { vertical-align: middle; padding: .85rem .75rem; }
.result-table tbody tr {
  transition: background .15s ease;
}
.result-table tbody tr:hover { background: #f7fbfc; }

/* Category / event tiles */
.cat-grid, .event-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(2, 1fr);
}
.tile {
  background: #fff;
  border: 1px solid var(--rh-line);
  border-radius: var(--rh-radius-sm);
  padding: 1rem;
  box-shadow: 0 8px 20px rgba(15, 36, 56, 0.05);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  height: 100%;
  display: block;
  color: inherit;
}
.tile:hover {
  transform: translateY(-2px);
  border-color: rgba(13, 115, 119, 0.35);
  box-shadow: var(--rh-shadow);
  color: inherit;
}
.tile .label { font-size: .78rem; color: var(--rh-muted); font-weight: 600; margin-bottom: .2rem; }
.tile strong { display: block; font-size: 1rem; margin-bottom: .25rem; }
.tile p { margin: 0; font-size: .86rem; color: var(--rh-muted); }

.breadcrumb-wrap {
  font-size: .9rem;
  color: var(--rh-muted);
  margin: .9rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}
.breadcrumb-wrap a { font-weight: 600; }

/* ---------- Bottom nav (mobile) ---------- */
.winner-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .4rem;
  padding-top: .55rem;
  border-top: 1px dashed var(--rh-line);
  font-size: .95rem;
}
.winner-label {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--rh-amber);
  border-radius: 999px;
  padding: .2rem .5rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 210;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--rh-line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  box-shadow: 0 -8px 24px rgba(15, 36, 56, 0.08);
}
.bottom-nav a {
  flex-direction: column;
  gap: .2rem;
  color: var(--rh-muted);
  font-size: .68rem;
  font-weight: 700;
  text-align: center;
  padding: .45rem .2rem;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active,
.bottom-nav a:hover { color: var(--rh-accent); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 2rem;
  background: #0f2438;
  color: #d5e2ec;
  padding: 2rem 0 calc(1.2rem + var(--bottom-nav-h));
}
.site-footer a { color: #8fdad4; font-weight: 600; }
.site-footer .muted { color: #8ea0b0; }
.site-footer .brand { color: #fff; }
.footer-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li + li { margin-top: .4rem; }

/* ---------- Admin ---------- */
.admin-shell { min-height: 100vh; background: #edf2f5; }
.admin-sidebar {
  width: 100%;
  background: #0f2438;
  color: #d7e2ea;
  position: relative;
  padding: .75rem;
}
.admin-sidebar .brand { color: #fff; margin-bottom: .5rem; padding: .35rem .5rem; }
.admin-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .35rem;
}
.admin-sidebar a {
  display: flex;
  align-items: center;
  color: #c5d4e0;
  padding: .65rem .75rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: .9rem;
  min-height: var(--touch);
  background: rgba(255, 255, 255, 0.04);
}
.admin-sidebar a:hover,
.admin-sidebar a.active {
  background: rgba(13, 115, 119, 0.4);
  color: #fff;
}
.admin-main { flex: 1; padding: 1rem; width: 100%; }
.kpi {
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--rh-line);
  padding: 1rem;
  height: 100%;
  transition: transform .18s ease;
}
.kpi:hover { transform: translateY(-2px); }
.kpi .label { color: var(--rh-muted); font-size: .82rem; font-weight: 600; }
.kpi .value {
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  font-weight: 800;
  font-family: var(--font-display);
  margin-top: .2rem;
}

.form-control, .form-select {
  min-height: var(--touch);
  font-size: 16px;
  border-radius: 10px;
}
.table-responsive { -webkit-overflow-scrolling: touch; }

.back-top {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px);
  z-index: 220;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--rh-ink);
  color: #fff;
  box-shadow: var(--rh-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.back-top.show { opacity: 1; pointer-events: auto; }
.back-top:hover { transform: translateY(-2px); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ============================================
   TABLET+
   ============================================ */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .site-footer { padding-bottom: 1.5rem; }
  .back-top { bottom: 1.5rem; }
  .brand-sub { display: block; }
  .hero { padding: 1.75rem 0 1rem; }
  .hero-panel { padding: 2.4rem 2.2rem; border-radius: 28px; }
  .hero-panel h1 { max-width: 14ch; }
  .search-panel {
    grid-template-columns: 1fr auto;
    padding: 1rem;
    align-items: center;
  }
  .search-panel .btn { border-radius: 999px; padding-inline: 1.5rem; }
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  .event-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: 1.4fr .8fr .8fr; }
  .result-cards { display: none; }
  .table-desktop { display: block; }
  .admin-nav { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================
   DESKTOP
   ============================================ */
@media (min-width: 992px) {
  .menu-toggle { display: none; }
  .mobile-drawer, .drawer-backdrop { display: none !important; }
  .desktop-nav {
    display: flex;
    align-items: center;
    gap: .2rem;
  }
  .admin-shell { display: flex; }
  .admin-sidebar {
    width: 260px;
    min-height: 100vh;
    position: sticky;
    top: 0;
    padding: 1.1rem .75rem;
  }
  .admin-nav {
    grid-template-columns: 1fr;
    gap: .2rem;
  }
  .admin-sidebar a {
    background: transparent;
    margin: 0 .25rem;
  }
  .admin-main { padding: 1.35rem 1.5rem; }
  .hero-panel {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

@media (min-width: 1200px) {
  :root { --container: 1200px; }
  .tile { padding: 1.15rem 1.2rem; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}