/* rigcheck.me — shared design system */

:root {
  color-scheme: light dark;

  /* Neutrals (one cool family, tinted toward the sky) */
  --bg: #eef2f6;
  --bg-sky: #d3e5f4;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --line: #dde4ec;
  --line-strong: #c9d3de;
  --ink: #0f1b2d;
  --ink-2: #4a5b70;
  --ink-3: #7a899c;

  /* Single brand accent, taken from Gilad's logo */
  --accent: #1d5fae;
  --accent-hover: #174f93;
  --accent-ink: #ffffff;
  --accent-soft: #e2edf9;

  /* Status */
  --ok: #23845a;
  --ok-soft: #e1f2e9;
  --warn: #a96f00;
  --warn-soft: #fbf0d6;
  --danger: #c4373b;
  --danger-soft: #fbe5e5;

  /* The altimeter is an instrument: always a dark face */
  --dial-face: #0d1623;
  --dial-face-2: #1a2738;
  --dial-ink: #eaf0f6;
  --dial-tick: rgba(234, 240, 246, 0.42);
  --dial-yellow: #f3c432;
  --dial-red: #e5484d;

  --shadow-sm: 0 1px 2px rgba(16, 38, 70, 0.06);
  --shadow-md: 0 1px 2px rgba(16, 38, 70, 0.05), 0 14px 36px -14px rgba(16, 48, 96, 0.22);
  --shadow-dial: 0 18px 40px -16px rgba(8, 24, 52, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 8px;

  --font-ui: "IBM Plex Sans Hebrew", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "Barlow Condensed", "IBM Plex Sans Condensed", "Arial Narrow", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --z-sheet: 20;
  --z-grain: 30;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a111b;
    --bg-sky: #13253b;
    --surface: #111b28;
    --surface-2: #162232;
    --line: #213042;
    --line-strong: #2c3e54;
    --ink: #e8eef5;
    --ink-2: #a5b3c4;
    --ink-3: #74869b;

    --accent: #6ea9ee;
    --accent-hover: #8bbcf3;
    --accent-ink: #08111c;
    --accent-soft: #15283f;

    --ok: #4cc38a;
    --ok-soft: #12291f;
    --warn: #f0b93a;
    --warn-soft: #2b2311;
    --danger: #f2696c;
    --danger-soft: #2f1618;

    --dial-face: #070d16;
    --dial-face-2: #121d2b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -16px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #0a111b;
  --bg-sky: #13253b;
  --surface: #111b28;
  --surface-2: #162232;
  --line: #213042;
  --line-strong: #2c3e54;
  --ink: #e8eef5;
  --ink-2: #a5b3c4;
  --ink-3: #74869b;
  --accent: #6ea9ee;
  --accent-hover: #8bbcf3;
  --accent-ink: #08111c;
  --accent-soft: #15283f;
  --ok: #4cc38a;
  --ok-soft: #12291f;
  --warn: #f0b93a;
  --warn-soft: #2b2311;
  --danger: #f2696c;
  --danger-soft: #2f1618;
  --dial-face: #070d16;
  --dial-face-2: #121d2b;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(130% 70% at 85% -20%, var(--bg-sky) 0%, transparent 62%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Fine grain so large flat areas don't feel sterile */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-hover);
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  inset-inline-start: 16px;
  top: -60px;
  z-index: 50;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  transition: top 0.2s var(--ease-out);
}

.skip-link:focus {
  top: 12px;
}

[hidden] {
  display: none !important;
}

/* ---------- Brand ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
}

.brand-word {
  direction: ltr;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand-word span {
  color: var(--ink-3);
  font-weight: 500;
}

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: var(--accent);
  --btn-ink: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s var(--ease-out), transform 0.15s var(--ease-out), box-shadow 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  --btn-bg: var(--accent-hover);
  color: var(--btn-ink);
}

.btn:active {
  transform: scale(0.98);
}

.btn[disabled],
.btn[aria-busy="true"] {
  cursor: progress;
  opacity: 0.75;
}

.btn-block {
  width: 100%;
}

.btn-quiet {
  --btn-bg: var(--surface-2);
  --btn-ink: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn-quiet:hover {
  --btn-bg: var(--accent-soft);
  --btn-ink: var(--ink);
}

.btn-whatsapp {
  --btn-bg: #1f8f55;
  --btn-ink: #ffffff;
}

.btn-whatsapp:hover {
  --btn-bg: #18774a;
}

.btn-icon {
  display: inline-flex;
}

.btn svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.btn .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.link-btn {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.link-btn:hover {
  color: var(--accent-hover);
}

.link-btn[disabled] {
  color: var(--ink-3);
  text-decoration: none;
  cursor: default;
}

/* ---------- Forms ---------- */

.field {
  display: grid;
  gap: 8px;
}

.field-label {
  font-size: 15px;
  font-weight: 600;
}

.input {
  width: 100%;
  min-height: 58px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font: 500 21px/1 var(--font-mono);
  letter-spacing: 0.02em;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.input::placeholder {
  color: var(--ink-3);
  opacity: 0.6;
}

.input[dir="ltr"] {
  text-align: right;
}

.input:hover {
  border-color: var(--ink-3);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-hint {
  color: var(--ink-3);
  font-size: 14px;
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--danger);
  font-size: 15px;
  font-weight: 500;
}

.field-error:empty {
  display: none;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15px;
  color: var(--ink-2);
  cursor: pointer;
}

.check input {
  appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background-color 0.15s, border-color 0.15s;
}

.check input::after {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--accent-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  transform: scale(0);
  transition: transform 0.15s var(--ease-out);
}

.check input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check input:checked::after {
  transform: scale(1);
}

.check input[aria-invalid="true"] {
  border-color: var(--danger);
}

/* ---------- Status chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 11px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: currentColor;
}

.chip-ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.chip-soon {
  color: var(--warn);
  background: var(--warn-soft);
}

.chip-critical,
.chip-expired {
  color: var(--danger);
  background: var(--danger-soft);
}

.chip-expired::before {
  animation: blink 1.6s ease-in-out infinite;
}

.chip-unknown {
  color: var(--ink-2);
  background: var(--surface-2);
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

/* ---------- Altimeter dial ---------- */

.dial {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(90% 90% at 30% 22%, var(--dial-face-2) 0%, var(--dial-face) 58%);
  box-shadow: var(--shadow-dial);
  isolation: isolate;
  container-type: inline-size;
}

.dial::before {
  /* bezel ring */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 0 0 7px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.dial::after {
  /* glass reflection */
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0) 38%);
  pointer-events: none;
  z-index: 2;
}

.dial svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.dial-numeral {
  fill: var(--dial-ink);
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 17px;
}

.dial-needle {
  /* user-space (0,0) is the dial center */
  transform-origin: 0 0;
  transform: rotate(var(--angle, 0deg));
}

.dial-needle.wind {
  /* winds down from a full cycle, like an altimeter after exit */
  animation: needle-wind 1.8s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

@keyframes needle-wind {
  from {
    transform: rotate(360deg);
  }
}

.dial-readout {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  color: var(--dial-ink);
  pointer-events: none;
}

.dial-value {
  font-family: var(--font-num);
  font-weight: 600;
  font-size: clamp(54px, 19cqi, 76px);
  line-height: 0.9;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.dial-unit {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.72;
}

.dial-value.is-text {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.1;
}

.dial[data-status="critical"] .dial-value,
.dial[data-status="expired"] .dial-value {
  color: var(--dial-red);
}

.dial[data-status="soon"] .dial-value {
  color: var(--dial-yellow);
}

/* ---------- Bottom sheet (terms, license) ---------- */

.sheet {
  width: min(560px, 100%);
  max-height: min(82dvh, 720px);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 -20px 60px -20px rgba(8, 20, 40, 0.45);
}

.sheet[open] {
  animation: sheet-in 0.32s var(--ease-out);
}

.sheet::backdrop {
  background: rgba(8, 16, 28, 0.5);
  backdrop-filter: blur(3px);
}

@media (min-width: 640px) {
  .sheet {
    margin: auto;
    border-radius: var(--radius-lg);
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

.sheet-inner {
  display: grid;
  gap: 18px;
  padding: 26px 24px calc(22px + env(safe-area-inset-bottom));
}

.sheet-title {
  font-size: 21px;
  font-weight: 700;
}

.sheet-text {
  color: var(--ink-2);
}

.sheet-actions {
  display: grid;
  gap: 10px;
}

.sheet-inner > .link-btn {
  justify-self: center;
}

.sheet-body {
  max-height: 52dvh;
  overflow-y: auto;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-line;
}

/* ---------- Footer ---------- */

.site-footer {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
  padding: 32px 0 calc(32px + env(safe-area-inset-bottom));
  color: var(--ink-3);
  font-size: 14px;
}

.footer-sign {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.footer-sign img {
  width: 54px;
  height: auto;
}

.footer-sign strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.footer-cred {
  display: block;
}

.footer-cred.ltr {
  font-size: 13px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
}

.footer-links a,
.footer-links button {
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
}

.footer-links a:hover,
.footer-links button:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-links button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

/* ---------- Motion ---------- */

.rise {
  animation: rise 0.7s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 80ms);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

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