/* ==========================================================================
   Staydays calculator pages (shared)
   Loaded after main.css on /schengen-calculator/, /183-day-calculator/,
   and /substantial-presence-test-calculator/ only.
   ========================================================================== */

/* 1. Hero
   -------------------------------------------------------------------------- */
.calc-hero { position: relative; overflow: hidden; padding-block: 44px 8px; }
@media (min-width: 960px) { .calc-hero { padding-block: 72px 12px; } }
.calc-hero .eyebrow { margin-bottom: 18px; }
.calc-hero .h1 { font-size: clamp(34px, 4.6vw, 52px); margin-bottom: 16px; max-width: 760px; }
.calc-hero .lead { max-width: 640px; }

/* 2. Tool card
   -------------------------------------------------------------------------- */
.calc-section { padding-block: 28px 20px; }

.calc-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.calc-columns { display: flex; flex-direction: column; }
.calc-col-form { padding: 24px 20px; }
.calc-col-results { padding: 24px 20px; background: var(--surface-2); border-top: 1px solid var(--line-soft); }
@media (min-width: 768px) {
  .calc-col-form, .calc-col-results { padding: 36px; }
}
@media (min-width: 1024px) {
  .calc-columns { flex-direction: row; align-items: stretch; }
  .calc-col-form { flex: 1; border-right: 1px solid var(--line-soft); min-width: 0; }
  .calc-col-results { width: 400px; flex-shrink: 0; border-top: none; }
}

.calc-card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 20px;
}

.calc-noscript {
  background: rgba(251, 81, 33, 0.1);
  border: 1px solid rgba(251, 81, 33, 0.35);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 20px;
}

/* 3. Form fields
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input,
.field select {
  background: var(--bg-inset);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--text-hi);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  color-scheme: dark;
}
.field input::placeholder { color: var(--muted); }
.field select option { background: var(--surface); color: #fff; }
.field input:focus-visible,
.field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* iOS WebKit currently adds a date input's padding outside width: 100%,
   which makes the control wider than its field. Keep the native picker, but
   move that padding to WebKit's internal value box so the outer border fits. */
@supports (-webkit-touch-callout: none) {
  .field input[type="date"] {
    min-height: 46px;
    padding: 0;
  }

  .field input[type="date"]::-webkit-date-and-time-value {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 11px 12px;
  }
}

.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 136px; }
.field-row .field-btn { flex: 0 0 auto; justify-content: flex-end; }

.field-hint { font-size: 11px; color: var(--muted); }

/* Compact control: caps short selects (e.g. a year picker) at a sensible width
   while staying full-width on narrow screens. */
.field-narrow { max-width: 240px; }

.calc-error { font-size: 13px; color: var(--accent); margin-top: 12px; }
.calc-error[hidden] { display: none; }

.calc-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}
.calc-options .field { flex: 1 1 150px; }
/* A field whose control cannot shrink (e.g. the segmented mode toggle)
   keeps its content width; siblings flex or wrap around it. */
.calc-options .field-fit { min-width: fit-content; }

/* Native date controls keep a large intrinsic width in mobile WebKit. Stack
   form groups before that width can push controls outside the calculator. */
@media (max-width: 479.98px) {
  .field-row,
  .calc-options { flex-direction: column; }

  .field-row > .field,
  .calc-options > .field {
    flex: 0 1 auto;
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .field-row .field-btn { align-items: stretch; }
  .field-row .field-btn .btn,
  .mode-toggle { width: 100%; }
}

.calc-actions {
  margin-top: 22px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

/* Segmented mode toggle (radio inputs) */
.mode-toggle {
  display: flex;
  align-items: stretch;
  background: var(--bg-inset);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.mode-toggle label { position: relative; display: flex; flex: 1 1 auto; min-width: 0; }
.mode-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.mode-toggle span {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}
@media (max-width: 359.98px) {
  .mode-toggle span { font-size: 12px; padding: 8px 7px; }
}
.mode-toggle input:checked + span {
  background: var(--surface);
  color: var(--text-hi);
  box-shadow: inset 0 0 0 1px var(--line);
}
.mode-toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 4. Stay list
   -------------------------------------------------------------------------- */
.stay-list { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.stay-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  padding: 12px 14px;
}
.stay-row-main { flex: 1; min-width: 0; }
.stay-row-label {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stay-row-range { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stay-row-days {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stay-remove {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stay-remove:hover { border-color: var(--accent); color: var(--accent); }
.stay-empty { text-align: center; padding: 22px 10px; color: var(--muted); font-size: 14px; }

/* 5. Results panel
   -------------------------------------------------------------------------- */
.calc-ring-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.calc-ring { width: 132px; height: 132px; }
.calc-ring .ring-value { font-size: 38px; letter-spacing: -0.04em; }
.calc-ring .ring-value.is-small { font-size: 22px; }
.calc-ring .ring-caption { font-size: 13px; }
.calc-ring-copy { flex: 1; min-width: 180px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.85);
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.status-pill.is-warn {
  background: rgba(251, 81, 33, 0.12);
  border-color: rgba(251, 81, 33, 0.4);
  color: var(--accent);
}
.status-pill.is-over {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.status-pill.is-over::before { background: #fff; }

.calc-verdict { font-size: 15px; font-weight: 600; line-height: 1.45; color: var(--text-hi); }

.calc-divider { height: 1px; background: var(--line-soft); margin: 24px 0; border: none; }

.result-tiles { display: flex; gap: 12px; flex-wrap: wrap; }
.result-tile {
  flex: 1 1 150px;
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 15px;
  min-width: 0;
}
.result-tile-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 7px; }
.result-tile-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1.1;
  overflow-wrap: break-word;
}
.result-tile-value.is-date {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-hi);
  line-height: 1.3;
  padding-top: 4px;
}
.result-tile-sub { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.45; }

/* Weighted arithmetic breakdown (substantial presence test) */
.math-lines { display: flex; flex-direction: column; gap: 9px; }
.math-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.math-line b { color: var(--text-hi); font-weight: 600; }
.math-line.math-total {
  border-top: 1px solid var(--line-soft);
  padding-top: 11px;
  color: var(--text-hi);
}
.math-line.math-total b { color: var(--accent); }

@media (max-width: 479.98px) {
  .math-line { flex-wrap: wrap; gap: 4px 12px; }
  .math-line > :last-child { margin-left: auto; text-align: right; }
}

/* 6. Timeline (180-day window)
   -------------------------------------------------------------------------- */
.calc-timeline { padding: 24px 20px 28px; border-top: 1px solid var(--line-soft); }
@media (min-width: 768px) { .calc-timeline { padding: 28px 36px 36px; } }
.calc-timeline-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.calc-timeline-title { font-size: 13px; font-weight: 600; }
.calc-timeline-range { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.timeline-bar {
  position: relative;
  display: flex;
  height: 14px;
  border-radius: 7px;
  background: var(--line-soft);
  overflow: hidden;
}
.timeline-seg { height: 100%; background: var(--line); min-width: 0; }
.timeline-seg.is-in { background: var(--accent); }

.timeline-legend { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 14px; }
.timeline-key {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-dim);
}
.timeline-key i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }

/* Meta line under the tool card */
.calc-meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.calc-meta[hidden] { display: none; }
.calc-card + .calc-meta { margin-top: 14px; }

/* 7. Article + sticky CTA aside
   -------------------------------------------------------------------------- */
.calc-article { display: flex; flex-direction: column; gap: 44px; align-items: flex-start; }
@media (min-width: 1060px) {
  .calc-article { flex-direction: row; gap: 64px; }
  .calc-article-body { max-width: 680px; }
  .calc-aside { width: 360px; flex-shrink: 0; position: sticky; top: 96px; }
}
.calc-aside { width: 100%; }
@media (min-width: 1060px) { .calc-aside { width: 360px; } }

.calc-article-body h2 {
  font-size: clamp(24px, 2.6vw, 30px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 40px 0 14px;
  scroll-margin-top: 90px;
}
.calc-article-body h2:first-child { margin-top: 0; }
.calc-article-body p {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 16px;
}
.calc-article-body ul {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
}
.calc-article-body li { margin-bottom: 6px; }
.calc-article-body strong { color: var(--text-hi); }

.cta-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  padding: 28px;
}
.cta-card .icon-tile { width: 48px; height: 48px; margin-bottom: 18px; }
.cta-card-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  text-wrap: balance;
}
.cta-card p { font-size: 14px; line-height: 1.6; color: var(--text-dim); margin: 0 0 20px; }

/* 8. Related tools and guides
   -------------------------------------------------------------------------- */
.related-links { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .related-links { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
.related-link {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  color: var(--text-hi);
  transition: border-color 0.15s ease-out;
}
.related-link:hover { border-color: rgba(255, 255, 255, 0.26); color: var(--text-hi); }
.related-link-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.related-link-title .arrow { color: var(--accent); flex-shrink: 0; }
.related-link-sub { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* 9. UK Statutory Residence Test extras
   (used only by /uk-statutory-residence-test-calculator/)
   -------------------------------------------------------------------------- */

/* Tie checkboxes */
.srt-ties {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}
.srt-ties > .field-label { margin-bottom: 2px; }
.srt-tie {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  padding: 12px 14px;
  cursor: pointer;
}
.srt-tie:hover { border-color: rgba(255, 255, 255, 0.24); }
.srt-tie[hidden] { display: none; }
.srt-tie input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
}
.srt-tie input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.srt-tie-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.srt-tie-name { font-size: 14px; font-weight: 600; color: var(--text-hi); }
.srt-tie-def { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* Margin insight line in the results panel */
.srt-margin {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  margin-top: 10px;
}

/* Sufficient-ties band table */
.srt-band-block { margin-bottom: 20px; }
.srt-band-title { font-size: clamp(20px, 2.4vw, 26px); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 10px; }
.srt-band-intro { font-size: 14px; line-height: 1.6; color: var(--text); max-width: 640px; margin-bottom: 18px; }
.srt-table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-md); }
.srt-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 320px; }
.srt-table th, .srt-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}
.srt-table thead th {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--bg-inset);
}
.srt-table tbody th { font-weight: 700; color: var(--text-hi); }
.srt-table tbody td { color: var(--text); }
.srt-table tbody tr:last-child th,
.srt-table tbody tr:last-child td { border-bottom: none; }
.srt-table tbody tr.is-active { background: rgba(251, 81, 33, 0.1); }
.srt-table tbody tr.is-active th { color: var(--accent); }
/* Emphasise the column that applies to the selected role */
.srt-table.show-leaver th:nth-child(3),
.srt-table.show-leaver td:nth-child(3) { color: var(--text-hi); font-weight: 700; }
.srt-table.show-arriver th:nth-child(2),
.srt-table.show-arriver td:nth-child(2) { color: var(--text-hi); font-weight: 700; }

/* "What this tool does not cover" box */
.srt-note {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.srt-note-title { font-size: 13px; font-weight: 700; color: var(--text-hi); margin-bottom: 8px; }
.srt-note p { font-size: 13px; line-height: 1.6; color: var(--text-dim); margin: 0; }
.srt-note a { color: var(--accent); }
