/* ==========================================================
   Tokens
   ========================================================== */
:root{
  --bg-0: #0a0d13;
  --bg-1: #10141c;
  --glass: rgba(255,255,255,0.045);
  --glass-strong: rgba(255,255,255,0.075);
  --border: rgba(255,255,255,0.09);
  --border-soft: rgba(255,255,255,0.06);
  --text-0: #eef1f6;
  --text-1: #a6adba;
  --text-2: #6b7280;

  --gold: #e3b357;
  --gold-soft: rgba(227,179,87,0.14);
  --teal: #52c7bd;

  --band-1: #c15a68;   /* limited      */
  --band-2: #cf8a4f;   /* basic        */
  --band-3: #d3bd57;   /* competent    */
  --band-4: #86b874;   /* strong       */
  --band-5: #4fbfa8;   /* outstanding  */

  --danger: #e0697a;

  --font-display: "Fraunces", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
html{ overflow-x: hidden; }
body{
  margin:0;
  font-family: var(--font-body);
  color: var(--text-0);
  background: var(--bg-0);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#bg-glow{
  position: fixed; inset: 0; z-index: -1; pointer-events:none;
  background:
    radial-gradient(60vw 60vh at 18% -6%, rgba(227,179,87,0.09), transparent 60%),
    radial-gradient(50vw 50vh at 100% 100%, rgba(82,199,189,0.07), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
}

::selection{ background: var(--gold-soft); color: var(--text-0); }

/* ==========================================================
   Glass primitive
   ========================================================== */
.glass{
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset, 0 20px 40px -20px rgba(0,0,0,0.6);
}

/* ==========================================================
   Layout helpers
   ========================================================== */
.view{ min-height: 100vh; min-height: 100dvh; }
.view--center{ display:flex; align-items:center; justify-content:center; padding:24px; }
[hidden]{ display:none !important; }

.eyebrow{
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 8px;
}

/* ==========================================================
   Login
   ========================================================== */
.card-login{
  width: 100%;
  max-width: 380px;
  padding: 36px 32px 32px;
}
.login-logo{
  display: block;
  max-height: 48px;
  max-width: 200px;
  margin: 0 0 18px;
  object-fit: contain;
}
.login-title{
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 6px;
}
.login-sub{
  color: var(--text-1);
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0 0 26px;
}

.field{ display:block; margin-bottom: 16px; }
.field span{
  display:block; font-size: 12.5px; color: var(--text-1);
  margin-bottom: 7px; font-weight: 500;
}
.field input{
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 14.5px;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.field input:focus{
  border-color: rgba(227,179,87,0.55);
  background: rgba(255,255,255,0.05);
}
.field input:focus-visible{ outline: 2px solid rgba(227,179,87,0.4); outline-offset: 2px; }

.form-error{
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--danger);
}

/* ==========================================================
   Buttons
   ========================================================== */
.btn{
  display: inline-flex; align-items:center; justify-content:center; gap:8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease, background .15s ease;
}
.btn:active{ transform: translateY(1px); }
.btn--block{ width: 100%; margin-top: 6px; }
.btn--primary{
  background: linear-gradient(180deg, var(--gold), #cf9a3f);
  color: #201404;
}
.btn--primary:hover{ filter: brightness(1.06); }
.btn--primary:disabled{ opacity:.6; cursor:default; }
.btn--ghost{
  background: transparent;
  border-color: var(--border);
  color: var(--text-1);
}
.btn--ghost:hover{ color: var(--text-0); border-color: rgba(255,255,255,0.2); }
.btn--sm{ padding: 8px 13px; font-size: 12.5px; }

.spinner{
  width:14px; height:14px; border-radius:50%;
  border: 2px solid rgba(0,0,0,0.25);
  border-top-color: rgba(0,0,0,0.75);
  animation: spin .7s linear infinite;
}
.btn--ghost .spinner{ border-color: rgba(255,255,255,0.2); border-top-color: rgba(255,255,255,0.7); }
@keyframes spin{ to{ transform: rotate(360deg); } }
.is-loading .btn-label{ opacity: .5; }

.icon-btn{
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-1);
  cursor: pointer;
  font-size: 13px;
  display:flex; align-items:center; justify-content:center;
}
.icon-btn:hover{ color: var(--text-0); background: rgba(255,255,255,0.07); }

/* ==========================================================
   Top bar / tabs
   ========================================================== */
.topbar{
  position: sticky; top:0; z-index: 20;
  display:flex; align-items:center; gap: 20px;
  padding: 14px 26px;
  padding-top: max(14px, env(safe-area-inset-top));
  padding-left: max(26px, env(safe-area-inset-left));
  padding-right: max(26px, env(safe-area-inset-right));
  background: rgba(10,13,19,0.72);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(18px);
}
.topbar-id{ display:flex; align-items:center; gap: 12px; min-width: 0; flex-shrink: 1; }
.topbar-id > div{ min-width: 0; }
.topbar-logo{
  height: 36px;
  max-width: 120px;
  object-fit: contain;
}
.topbar-mark{
  width: 36px; height:36px; border-radius: 10px;
  display:flex; align-items:center; justify-content:center;
  background: var(--gold-soft);
  color: var(--gold);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid rgba(227,179,87,0.3);
}
.topbar-title{ margin:0; font-family: var(--font-display); font-weight:600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-judge{ margin:0; font-size: 11.5px; color: var(--text-2); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs{ display:flex; gap: 4px; margin-left: 8px; }
.tab{
  background: transparent; border: none; cursor: pointer;
  color: var(--text-1); font-family: var(--font-body); font-weight: 600; font-size: 13.5px;
  padding: 8px 14px; border-radius: 999px;
  transition: color .15s ease, background .15s ease;
}
.tab:hover{ color: var(--text-0); }
.tab.is-active{ color: #201404; background: var(--gold); }

.topbar-actions{ margin-left: auto; display:flex; align-items:center; gap: 12px; }
.sync-pill{
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em;
  color: var(--teal); background: rgba(82,199,189,0.12);
  border: 1px solid rgba(82,199,189,0.3);
  padding: 5px 10px; border-radius: 999px;
}
.sync-pill.is-busy{ color: var(--gold); background: var(--gold-soft); border-color: rgba(227,179,87,0.3); }
.sync-pill.is-error{ color: var(--danger); background: rgba(224,105,122,0.12); border-color: rgba(224,105,122,0.3); }

/* ==========================================================
   Panels
   ========================================================== */
.panel{ padding: 30px 26px 70px; max-width: 1180px; margin: 0 auto; }
.panel-head h2{ font-family: var(--font-display); font-size: 24px; margin: 0 0 4px; }
.panel-sub{ color: var(--text-1); font-size: 13.5px; margin: 0 0 24px; }

.country-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.country-card{
  text-align: left;
  cursor: pointer;
  padding: 18px 18px 16px;
  color: var(--text-0);
  font-family: var(--font-body);
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.country-card:hover{ transform: translateY(-2px); border-color: rgba(227,179,87,0.35); background: rgba(255,255,255,0.065); }
.country-name{ font-family: var(--font-display); font-size: 18px; font-weight: 600; margin: 0 0 10px; }
.country-meta{ display:flex; align-items:center; justify-content: space-between; }
.country-score{ font-family: var(--font-mono); font-size: 13px; color: var(--text-1); }
.country-score b{ color: var(--gold); font-size: 15px; }
.country-status{
  margin-left: auto;
  font-size: 10.5px; font-family: var(--font-mono); letter-spacing: .05em;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--border-soft); color: var(--text-2);
}
.country-status.is-scored{ color: var(--teal); border-color: rgba(82,199,189,0.35); background: rgba(82,199,189,0.08); }

.score-list{ display:flex; flex-direction:column; gap: 10px; }
.score-row{
  display:flex; align-items:center; justify-content: space-between;
  padding: 16px 18px;
  cursor: pointer;
  color: var(--text-0);
  text-align: left;
}
.score-row:hover{ border-color: rgba(227,179,87,0.3); }
.score-row-name{ font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--text-0); }
.score-row-sub{ font-size: 12px; color: var(--text-2); margin-top: 2px; }
.score-row-total{ font-family: var(--font-mono); font-size: 20px; color: var(--gold); }
.score-row-total span{ font-size: 12px; color: var(--text-2); }
.empty-state{ color: var(--text-2); font-size: 13.5px; padding: 30px 4px; }

/* ==========================================================
   Drawer
   ========================================================== */
.drawer-backdrop{
  position: fixed; inset:0; background: rgba(6,8,12,0.55);
  backdrop-filter: blur(2px); z-index: 30;
}
.drawer{
  position: fixed; top:0; right:0; height: 100vh; height: 100dvh;
  width: min(560px, 100vw);
  z-index: 31;
  background: linear-gradient(180deg, #12161f 0%, #0d1017 100%);
  border-left: 1px solid var(--border);
  display:flex; flex-direction:column;
  box-shadow: -30px 0 60px -30px rgba(0,0,0,0.7);
  animation: slidein .22s ease;
}
@keyframes slidein{ from{ transform: translateX(24px); opacity:0; } to{ transform: translateX(0); opacity:1; } }

.drawer-head{
  display:flex; align-items:flex-start; justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.drawer-head h2{ font-family: var(--font-display); font-size: 21px; margin: 0; }

.drawer-body{ flex:1; overflow-y:auto; padding: 6px 24px 20px; }

.criterion{ padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.criterion:last-child{ border-bottom: none; }
.criterion-title{ font-size: 13.5px; font-weight: 600; margin: 0 0 3px; }
.criterion-q{ font-size: 12px; color: var(--text-2); margin: 0 0 12px; line-height: 1.45; }

.pip-row{ display:flex; gap: 6px; }
.pip{
  flex:1; height: 34px; border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-1);
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: transform .08s ease, background .12s ease, border-color .12s ease, color .12s ease;
}
.pip:hover{ transform: translateY(-1px); color: var(--text-0); }
.pip[data-band="1"]:hover{ border-color: var(--band-1); }
.pip[data-band="2"]:hover{ border-color: var(--band-2); }
.pip[data-band="3"]:hover{ border-color: var(--band-3); }
.pip[data-band="4"]:hover{ border-color: var(--band-4); }
.pip[data-band="5"]:hover{ border-color: var(--band-5); }

.pip.is-selected{ color: #14110a; font-weight: 700; }
.pip.is-selected[data-band="1"]{ background: var(--band-1); border-color: var(--band-1); }
.pip.is-selected[data-band="2"]{ background: var(--band-2); border-color: var(--band-2); }
.pip.is-selected[data-band="3"]{ background: var(--band-3); border-color: var(--band-3); }
.pip.is-selected[data-band="4"]{ background: var(--band-4); border-color: var(--band-4); }
.pip.is-selected[data-band="5"]{ background: var(--band-5); border-color: var(--band-5); }

.pip-legend{
  display:flex; justify-content: space-between;
  margin-top: 7px; font-size: 10px; color: var(--text-2);
  font-family: var(--font-mono); letter-spacing: .01em;
}

.drawer-foot{
  display:flex; align-items:center; justify-content: space-between;
  padding: 18px 24px 22px;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft);
}
.total-readout{ display:flex; flex-direction:column; }
.total-label{ font-size: 11px; color: var(--text-2); font-family: var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.total-value{ font-family: var(--font-mono); font-size: 26px; color: var(--gold); font-weight: 600; }
.total-max{ font-size: 14px; color: var(--text-2); }

/* ==========================================================
   Floating rubric tooltip
   ========================================================== */
.rubric-tooltip{
  position: fixed; z-index: 60; pointer-events:none;
  width: 260px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(18,22,31,0.96);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px -12px rgba(0,0,0,0.65);
}
.rt-band{ margin:0 0 5px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--gold); }
.rt-desc{ margin:0; font-size: 12.5px; line-height: 1.5; color: var(--text-0); }

/* ==========================================================
   Toast
   ========================================================== */
.toast{
  position: fixed; left: 50%; bottom: max(28px, calc(env(safe-area-inset-bottom) + 16px)); transform: translateX(-50%);
  z-index: 70;
  max-width: calc(100vw - 32px);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  background: rgba(18,22,31,0.95);
  border: 1px solid var(--border);
  color: var(--text-0);
  animation: rise .18s ease;
}
.toast.is-error{ color: var(--danger); border-color: rgba(224,105,122,0.35); }
@keyframes rise{ from{ opacity:0; transform: translate(-50%, 8px);} to{ opacity:1; transform: translate(-50%,0);} }

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 640px){
  .topbar{ flex-wrap: wrap; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  .tabs{ order: 3; width: 100%; margin-left: 0; }
  .tab{ flex: 1; text-align: center; padding: 8px 6px; }
  .topbar-actions{ margin-left: auto; }
  .panel{ padding: 22px 16px 70px; }
  .drawer{ width: 100vw; }
  .drawer-head{ padding: 18px 18px 14px; }
  .drawer-head h2{ font-size: 18px; }
  .drawer-body{ padding: 4px 18px 16px; }
  .drawer-foot{ padding-left: 18px; padding-right: 18px; }
  .rubric-tooltip{ display:none; } /* no hover on touch; band name shown inline instead */

  .view--center{ padding: 16px; align-items: flex-start; padding-top: max(40px, calc(env(safe-area-inset-top) + 24px)); }
  .card-login{ padding: 28px 22px 24px; max-width: 100%; }

  .country-grid{ grid-template-columns: 1fr; }
  .pip-row{ flex-wrap: wrap; }
  .pip{ flex: 1 1 calc(20% - 5px); min-width: 30px; }
  .pip-legend span{ font-size: 9px; }
}

/* Very small phones (SE-class, ~375px and under) */
@media (max-width: 380px){
  .country-name{ font-size: 16px; }
  .criterion-title{ font-size: 12.5px; }
  .pip{ height: 30px; font-size: 11px; }
  .pip-legend{ display: none; } /* the pip colour + tap-and-hold tooltip still convey the band */
  .total-value{ font-size: 21px; }
  .btn--sm{ padding: 7px 10px; font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
