/* icp — Cloud Storage Price Index
   Plain CSS, no external fonts or icon libraries. Light palette is the default
   and mirrors the compact card + dense table look of the reference site. */

:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #5b6676;
  --subtle: #98a2b3;
  --line: #e5e9f0;
  --line-soft: #eef1f6;
  --line-strong: #d5dbe5;
  --head: #f8fafc;
  --row-alt: #f7f9fc;
  --blue: #2563eb;
  --blue-bright: #3b82f6;
  --blue-soft: #eff6ff;
  --green: #0a8a5f;
  --green-soft: #e9f9f1;
  --badge-ink: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05);
  --radius: 10px;
  --row-h: 56px;
  --head-h: 38px;
  --visible-rows: 10;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: light;
}

/* Two dark sources: an explicit choice and the system fallback. */
[data-theme="dark"] {
  --bg: #070c15;
  --card: #0f1a2b;
  --ink: #e9eff8;
  --muted: #a3b1c6;
  --subtle: #7f8ea6;
  --line: #2a3b58;
  --line-soft: #1c2a42;
  --line-strong: #354a6b;
  --head: #16253c;
  --row-alt: #0c1524;
  --blue: #8ab8ff;
  --blue-bright: #6aa9ff;
  --blue-soft: #182c49;
  --green: #34d399;
  --green-soft: #0e3328;
  --badge-ink: #04231a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070c15;
    --card: #0f1a2b;
    --ink: #e9eff8;
    --muted: #a3b1c6;
    --subtle: #7f8ea6;
    --line: #2a3b58;
    --line-soft: #1c2a42;
    --line-strong: #354a6b;
    --head: #16253c;
    --row-alt: #0c1524;
    --blue: #8ab8ff;
    --blue-bright: #6aa9ff;
    --blue-soft: #182c49;
    --green: #34d399;
    --green-soft: #0e3328;
    --badge-ink: #04231a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; }

/* ---------- states ---------- */
.state--center {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}
.state__text { margin: 0; color: var(--muted); font-size: 14px; }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--blue-bright);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-card { width: min(100%, 420px); padding: 24px; text-align: center; }
.error-card__title { margin: 0 0 8px; font-size: 22px; color: #ef4444; }
.error-card__msg { margin: 0 0 6px; color: var(--ink); }
.error-card__hint { margin: 0 0 18px; color: var(--muted); font-size: 12.5px; }
.error-card code { font-size: 11.5px; background: var(--head); padding: 1px 4px; border-radius: 3px; }

/* ---------- shell / cards ---------- */
.shell {
  width: 100%;
  max-width: 1200px;
  height: 100vh;
  height: 100svh;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  flex: 0 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hero__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 34px;
}
.brand {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  white-space: nowrap;
}
.brand__mark {
  width: 11px; height: 11px; border-radius: 3px;
  background: linear-gradient(135deg, var(--blue-bright), #8ec5ff);
}
.brand__sep { color: var(--subtle); font-weight: 400; }

.hero__heading {
  display: flex; align-items: baseline; justify-content: center;
  gap: 12px; min-width: 0;
}
.hero__title {
  margin: 0;
  font-size: 22px; font-weight: 700; letter-spacing: -.025em;
  color: var(--blue); white-space: nowrap;
}
.hero__subtitle { color: var(--muted); font-size: 13px; font-weight: 400; white-space: nowrap; }

.hero__bar {
  margin: 0; padding: 0; border: 0;
  display: flex; flex-wrap: nowrap; align-items: center;
  justify-content: center; gap: 16px;
  min-height: 34px;
}
.meta-note {
  margin: 0; color: var(--subtle); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.meta-note__sep { padding: 0 3px; }
.tools { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; flex: 0 0 auto; }

.field { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.field select, .field input {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  padding: 0 8px;
}
.field select { cursor: pointer; }
.field input { width: 132px; }
.field input::placeholder { color: var(--subtle); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 34px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 6px;
  font: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn--sm { height: 34px; }
.btn--outline { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn--outline:hover:not(:disabled) { background: var(--head); }
.btn--primary { background: var(--blue-bright); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--blue); }
.btn__icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.theme-btn {
  justify-self: end;
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--muted);
  font: inherit; font-size: 11.5px; cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.theme-btn:hover { background: var(--head); color: var(--ink); }
.theme-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: none; }
[data-mode="auto"] .theme-icon--auto { display: block; }
[data-mode="light"] .theme-icon--light { display: block; }
[data-mode="dark"] .theme-icon--dark { display: block; }

/* ---------- table ---------- */
.table-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* fills the card; app.js rewrites --row-h so --visible-rows rows fit exactly */
.table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.grid { width: 100%; min-width: 980px; border-collapse: collapse; }

.grid th, .grid td { border-bottom: 1px solid var(--line-soft); padding: 10px 14px; }
.grid thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--head);
  color: var(--muted);
  font-size: 11px; font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 8px 12px;
  height: var(--head-h);
  border-bottom: 1px solid var(--line-strong);
}
.grid .col-country { min-width: 190px; text-align: left; }
.grid .col-currency { min-width: 84px; text-align: left; }
.grid .col-tier { min-width: 140px; text-align: right; }
/* hairline keeps the label block visually apart from the price block */
.grid th.col-currency, .grid td.col-currency { border-right: 1px solid var(--line-soft); }

/* Keep the region name visible while scrolling sideways on small screens. */
.grid th.col-country, .grid td.col-country {
  position: sticky; left: 0; z-index: 2; background: var(--card);
  box-shadow: 1px 0 0 var(--line-soft);
}
.grid thead th.col-country {
  z-index: 4; background: var(--head);
  box-shadow: 1px 0 0 var(--line-strong);
}

.sort {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.sort:hover { background: var(--blue-soft); }
th[aria-sort] .sort { color: var(--blue); font-weight: 600; }
.arrows {
  display: inline-flex; flex-direction: column; gap: 2px;
  opacity: .3; transition: opacity .15s ease;
}
th:hover .arrows, th[aria-sort] .arrows { opacity: 1; }
.arrow { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.arrow--up { border-bottom: 5px solid var(--subtle); }
.arrow--down { border-top: 5px solid var(--subtle); }
.arrow.is-on { border-bottom-color: var(--blue-bright); border-top-color: var(--blue-bright); }

.grid tbody tr { height: var(--row-h); transition: background-color .12s ease; }
/* alternate rows: on dark the border alone is not enough to separate 17 rows */
.grid tbody tr:nth-child(even) td { background: var(--row-alt); }
.grid tbody tr:nth-child(even) td.col-country { background: var(--row-alt); }
.grid tbody tr:nth-child(even) td.is-best { background: var(--green-soft); }
.grid tbody tr:hover td { background: var(--blue-soft); }
.grid tbody tr:hover td.col-country { background: var(--blue-soft); }
.grid td.col-currency { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .06em; }
.grid td.cell-price { text-align: right; }
.grid td.is-best, .grid tbody tr:hover td.is-best { background: var(--green-soft); }

.flag { margin-right: 9px; font-size: 15px; line-height: 1; }
.region { font-size: 14.5px; font-weight: 600; letter-spacing: -.005em; }
.price {
  font-weight: 700; font-size: 15px; line-height: 1.15;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.price__cur {
  color: var(--muted); font-size: 10px; font-weight: 700;
  letter-spacing: .06em; margin-left: 5px; text-transform: uppercase;
}
.converted {
  margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 500;
  line-height: 1.2; font-variant-numeric: tabular-nums;
}
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  border-radius: 999px; background: var(--green); color: var(--badge-ink);
  font-size: 10px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; vertical-align: 1px;
}
.na { color: var(--subtle); }
.empty-row td { padding: 34px 12px; text-align: center; color: var(--subtle); }

.table-foot {
  flex: 0 0 auto;
  margin: 0; padding: 11px 14px;
  border-top: 1px solid var(--line);
  color: var(--subtle); font-size: 11.5px;
}
.table-foot__sep { padding: 0 6px; }

.footer {
  flex: 0 0 auto;
  margin-top: auto;
  color: var(--subtle); font-size: 10.5px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 10px);
  padding: 9px 16px; border-radius: 8px;
  background: var(--ink); color: var(--card);
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 20;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .hero__subtitle { display: none; }
  .meta-note { max-width: 260px; }
}
@media (max-width: 900px) {
  .meta-note { display: none; }
}

@media (max-width: 720px) {
  :root { --row-h: 52px; --head-h: 36px; }
  .shell { padding: 8px; gap: 8px; }
  .hero { padding: 14px; gap: 10px; }
  .hero__row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
  .hero__heading { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .hero__title { font-size: 17px; }
  .theme-btn { grid-column: 2; grid-row: 1; }
  .hero__bar { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 6px; }
  .meta-note { display: block; max-width: none; font-size: 10.5px; white-space: nowrap; }
  .meta-note__prefix { display: none; }
  #ratesUpdated { white-space: nowrap; }
  /* two compact rows: [currency | filter] then [refresh | share] */
  .tools { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .field__label { display: none; }
  .field--select, .field--search { grid-column: auto; min-width: 0; }
  .field--select select, .field--search input { flex: 1; width: 100%; min-width: 0; }
  .btn--sm { width: 100%; font-size: 12px; padding: 0 8px; }
  .theme-btn__label { display: none; }
  .grid { min-width: 820px; }
  .grid th, .grid td { padding: 6px 8px; }
  .grid .col-country { min-width: 168px; }
  .region { font-size: 13.5px; }
  .grid .col-tier { min-width: 118px; }
  .price { font-size: 14px; }
  .price__cur { margin-left: 3px; }
  .table-foot { padding: 6px 10px; font-size: 11px; }
  .footer { font-size: 10px; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
