/* Gulf Work Calc: shared stylesheet. Mobile-first.
   Theme: light is always the default, whatever the OS setting. Dark only when the visitor
   picks it with the header toggle, which sets <html data-theme="dark">. */

:root {
  /* Colors */
  /* Accent: buttons, links, logo, focus rings and active states only.
     Success: the main result figure only. */
  --bg: #ffffff;
  --surface: #f8fafc;
  --border: #e2e8f0;
  --border-input: #7c8799; /* 3.6:1 on bg, WCAG 1.4.11 for input boundaries */
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1e3a8a;
  --accent-hover: #172e6e;
  --accent-text: #ffffff;
  --success: #15803d;
  --error: #b91c1c;
  --logo-bg: #1e3a8a;
  --logo-text: #ffffff;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 4px 16px rgb(15 23 42 / 0.06);
  color-scheme: light;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;

  /* Spacing scale 4/8/12/16/24/32/48 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --radius: 8px;
  --control-h: 44px;
  --page: 72rem;
  --prose: 46rem;
}

/* Dark theme: only when chosen with the toggle. */
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111827;
  --border: #1f2937;
  --border-input: #5b6b82; /* 3.5:1 on bg */
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-text: #0b1220;
  --success: #4ade80;
  --error: #f87171;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-base)/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; margin: 0 0 var(--s2); }
h2 { font-size: 1.25rem; margin: 0 0 var(--s4); }
h3 { font-size: var(--fs-base); margin: var(--s5) 0 var(--s3); }
p { margin: 0 0 var(--s4); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--page); margin: 0 auto; padding: 0 var(--s4); }
.prose { max-width: var(--prose); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link { position: absolute; left: -999px; top: 0; padding: var(--s2) var(--s4); background: var(--bg); }
.skip-link:focus { left: var(--s4); }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--bg); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); height: 64px; }
.brand { display: inline-flex; align-items: center; gap: var(--s3); color: var(--text); font-weight: 650; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand img { flex: none; display: block; }
.site-nav { display: flex; align-items: center; gap: var(--s3); font-size: var(--fs-sm); }
.site-nav a { color: var(--text); }
.site-nav a:hover { color: var(--accent); }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle[aria-pressed="true"] .icon-moon,
.theme-toggle[aria-pressed="false"] .icon-sun { display: none; }

main { padding: var(--s5) 0 var(--s7); }

/* Breadcrumb + page head */
.breadcrumb { margin-top: var(--s4); }
.breadcrumb ol { display: flex; gap: var(--s2); list-style: none; margin: 0 0 var(--s4); padding: 0; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.breadcrumb li { flex: none; }
.breadcrumb li:last-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb li + li::before { content: "/"; margin-right: var(--s2); color: var(--muted); opacity: 0.6; }
.breadcrumb a { color: var(--muted); }
.page-head { margin-bottom: var(--s5); }
.intro { color: var(--muted); font-size: var(--fs-lg); margin-bottom: var(--s3); }
/* Inline text that wraps naturally, items separated by dots */
.trust { margin: 0; padding: 0; font-size: var(--fs-sm); color: var(--muted); line-height: 1.7; }
.trust li { display: inline; list-style: none; }
.trust li + li::before { content: "\00B7"; margin: 0 var(--s2); }
.byline { margin: var(--s1) 0 0; font-size: var(--fs-sm); color: var(--muted); }
.byline a { color: inherit; font-weight: 600; }

/* About page author card */
.author-card { display: flex; gap: var(--s4); align-items: flex-start; margin: var(--s5) 0; padding: var(--s4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.author-card p { margin: 0 0 var(--s2); }
.author-card p:last-child { margin-bottom: 0; }
.author-name span { color: var(--muted); font-size: var(--fs-sm); }
.author-photo { flex: none; width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.author-initials { display: grid; place-items: center; background: var(--logo-bg); color: var(--logo-text); font-size: 1.375rem; font-weight: 700; }

/* Calculator layout */
.calc-grid { display: grid; gap: var(--s5); margin-bottom: var(--s7); align-items: start; }
.calc-form {
  display: grid; gap: var(--s4); margin: 0;
  padding: var(--s4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.row-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--s3); row-gap: var(--s2); }
/* Label, input, hint and error line up across both columns, even when one label wraps. */
.row-2 > .field { grid-row: span 4; grid-template-rows: subgrid; }
.field { display: grid; gap: var(--s2); align-content: start; min-width: 0; }
.field label { font-size: var(--fs-sm); font-weight: 600; overflow-wrap: anywhere; } /* wrap, never cut */
.field .optional { font-weight: 400; color: var(--muted); }
.hint { font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }
.error { font-size: var(--fs-xs); color: var(--error); font-weight: 500; line-height: 1.45; }
.error:empty { display: none; }
.calc-form [hidden] { display: none; }

/* Radio group shown as tappable cards: stacked on mobile, side by side from 40rem. */
.choice-group { display: grid; gap: var(--s2); min-width: 0; margin: 0; padding: 0; border: 0; }
.choice-group legend { padding: 0; margin-bottom: var(--s2); font-size: var(--fs-sm); font-weight: 600; }
.choices { display: grid; gap: var(--s2); }
.choice {
  display: flex; align-items: center; gap: var(--s3); min-height: var(--control-h); min-width: 0;
  padding: var(--s2) var(--s3); border: 1px solid var(--border-input); border-radius: var(--radius);
  background: var(--bg); cursor: pointer; line-height: 1.3; transition: border-color 0.15s;
}
.choice:hover { border-color: var(--text); }
.choice input { flex: none; width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--accent); cursor: pointer; }
.choice span { min-width: 0; overflow-wrap: anywhere; }
.choice:has(input:checked) {
  border-color: var(--accent); font-weight: 600;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice-group[aria-invalid="true"] .choice { border-color: var(--error); }

.control {
  position: relative; display: flex; align-items: center;
  height: var(--control-h); width: 100%; min-width: 0;
  border: 1px solid var(--border-input); border-radius: var(--radius); background: var(--bg);
  transition: border-color 0.15s;
}
.control:hover { border-color: var(--text); }
.control:focus-within { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.control:has([aria-invalid="true"]) { border-color: var(--error); }
.control input, .control select {
  flex: 1 1 0; min-width: 0; width: 0; height: 100%; margin: 0;
  padding: 0 var(--s3); border: 0; border-radius: var(--radius);
  background: transparent; color: var(--text);
  font: inherit; font-variant-numeric: tabular-nums; line-height: normal;
  appearance: none; -webkit-appearance: none;
}
.control input:focus, .control select:focus { outline: none; }
.control input[type="date"] { min-width: 0; padding-right: var(--s2); }
.control input::-webkit-date-and-time-value { text-align: left; }
.control input::-webkit-calendar-picker-indicator { opacity: 0.6; cursor: pointer; }
.control .prefix {
  padding-left: var(--s3); color: var(--muted); font-size: var(--fs-sm); font-weight: 600;
  pointer-events: none;
}
.control .prefix + input { padding-left: var(--s2); }
.control.select::after {
  content: ""; position: absolute; right: var(--s4); top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg);
  pointer-events: none;
}
.control.select select { padding-right: var(--s6); cursor: pointer; }
.control select option { color: #0f172a; background: #ffffff; }

.notice {
  margin: 0; font-size: var(--fs-sm); color: var(--muted);
  padding: var(--s3) var(--s4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: var(--control-h); padding: 0 var(--s5);
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; gap: var(--s1);
  height: 32px; padding: 0 var(--s3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--muted);
  font: inherit; font-size: var(--fs-xs); font-weight: 500; cursor: pointer;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 14px; height: 14px; }

/* Result card */
.result-card {
  min-width: 0; padding: var(--s4); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.result-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.result-head h2 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; }
.result-actions { display: flex; gap: var(--s2); }
.result-card[data-state="empty"] .result-actions,
.result-card[data-state="empty"] .result-body { display: none; }
.result-card:not([data-state="empty"]) .empty-state { display: none; }
.empty-state { color: var(--muted); padding: var(--s6) 0; text-align: center; margin: 0; }
.primary-label { font-size: var(--fs-sm); color: var(--muted); margin: 0 0 var(--s1); }
.primary-figure { font-size: 2rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 var(--s1); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--success); }
.primary-figure.is-zero { color: var(--text); }
.primary-figure .unit { font-size: var(--fs-base); font-weight: 500; color: var(--muted); letter-spacing: 0; }
.primary-sub { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s4); }
.status { font-size: var(--fs-xs); color: var(--text); margin: var(--s3) 0 0; min-height: 1.4em; }

.breakdown { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.breakdown th, .breakdown td { padding: var(--s2) 0; border-top: 1px solid var(--border); vertical-align: top; text-align: left; font-weight: 400; }
.breakdown td { text-align: right; padding-left: var(--s4); white-space: nowrap; font-variant-numeric: tabular-nums; }
.breakdown .note { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; font-variant-numeric: tabular-nums; }
.breakdown tr.total th, .breakdown tr.total td { font-weight: 700; font-size: var(--fs-base); border-top-color: var(--text); padding-top: var(--s3); }
.card-foot { margin: var(--s4) 0 0; font-size: var(--fs-xs); color: var(--muted); }

/* Content sections */
.section { margin-bottom: var(--s7); }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: var(--s4); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th, .data-table td { padding: var(--s3) var(--s4); text-align: left; vertical-align: top; }
.data-table thead th { background: var(--surface); color: var(--muted); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tbody tr th, .data-table tbody tr td { border-top: 1px solid var(--border); }
.data-table tbody th { font-weight: 500; }
.data-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table tr.total th, .data-table tr.total td { font-weight: 700; }
.formula { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Stacked tables on small screens: label on top, value below. */
@media (max-width: 39.99rem) {
  .stack-sm thead { display: none; }
  .stack-sm tr { display: block; padding: var(--s3) var(--s4); }
  .stack-sm tbody tr + tr { border-top: 1px solid var(--border); }
  .stack-sm th, .stack-sm td { display: block; padding: 0 !important; border: 0 !important; text-align: left !important; }
  .stack-sm th { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; margin-bottom: var(--s1); }
}

.source-list { padding-left: var(--s5); margin: 0 0 var(--s4); }
.source-list li { margin-bottom: var(--s1); }

/* FAQ accordion */
.faq { border-top: 1px solid var(--border); }
.faq details { border-bottom: 1px solid var(--border); interpolate-size: allow-keywords; }
.faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s4) 0; cursor: pointer; font-weight: 600; list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; flex: none; width: 16px; text-align: center;
  font-size: 1.25rem; font-weight: 400; line-height: 1; color: var(--muted);
}
.faq details[open] > summary::after { content: "\2212"; color: var(--accent); }
.faq summary:hover { color: var(--accent); }
.faq details::details-content {
  block-size: 0; overflow: hidden;
  transition: block-size 0.25s ease, content-visibility 0.25s allow-discrete;
}
.faq details[open]::details-content { block-size: auto; }
.faq details p { color: var(--muted); padding-bottom: var(--s4); margin: 0; }

/* Cards (related tools, home list) */
.card-grid { display: grid; gap: var(--s4); list-style: none; padding: 0; margin: 0; }
.card {
  display: block; height: 100%; padding: var(--s4) var(--s5);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text);
  transition: border-color 0.15s;
}
a.card:hover { border-color: var(--accent); text-decoration: none; color: var(--text); }
.card strong { display: block; margin-bottom: var(--s1); }
.card span { display: block; color: var(--muted); font-size: var(--fs-sm); }
.soon-list { color: var(--muted); padding-left: var(--s5); }

/* Homepage */
.hero { padding: var(--s5) 0 var(--s5); max-width: var(--prose); }
.hero h1 { font-size: 2rem; }

.country-filter { margin-bottom: var(--s5); }
.filter-label { font-size: var(--fs-sm); font-weight: 600; margin: 0 0 var(--s2); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s2); }
.chip {
  height: 36px; padding: 0 var(--s4);
  border: 1px solid var(--border-input); border-radius: 999px; background: var(--bg); color: var(--text);
  font: inherit; font-size: var(--fs-sm); font-weight: 500; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.filter-status { font-size: var(--fs-sm); color: var(--muted); min-height: 1.6em; margin: 0; }

.tool-grid { display: grid; gap: var(--s4); list-style: none; padding: 0; margin: 0; }
.tool-grid > li[hidden] { display: none; }
.tool-card {
  display: flex; flex-direction: column; gap: var(--s2); height: 100%;
  padding: var(--s5); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  transition: border-color 0.15s;
}
a.tool-card:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.tool-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); }
.tool-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.tool-icon .icon { width: 20px; height: 20px; }
.badge {
  display: inline-block; padding: 2px var(--s2); border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
}
.tool-title { font-size: var(--fs-base); line-height: 1.35; }
.tool-desc { color: var(--muted); font-size: var(--fs-sm); flex: 1; }
.tool-go { margin-top: var(--s2); font-size: var(--fs-sm); font-weight: 600; color: var(--accent); }
.tool-go .arrow { display: inline-block; transition: transform 0.15s; }
a.tool-card:hover .arrow { transform: translateX(3px); }

.why-list { display: grid; gap: var(--s5); list-style: none; padding: 0; margin: 0; }
.why-list li { display: grid; grid-template-columns: 40px 1fr; column-gap: var(--s4); row-gap: var(--s1); }
.why-icon {
  grid-row: span 2; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.why-icon .icon { width: 20px; height: 20px; }
.why-list span:last-child { color: var(--muted); font-size: var(--fs-sm); }

.guide { padding-top: var(--s6); border-top: 1px solid var(--border); }
.guide ul { padding-left: var(--s5); margin: 0 0 var(--s4); }
.guide li { margin-bottom: var(--s2); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: var(--s6) 0 var(--s5); font-size: var(--fs-sm); }
.footer-cols { display: grid; gap: var(--s5); margin-bottom: var(--s5); }
.footer-cols h2 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 var(--s3); }
.footer-cols ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s2); }
.footer-cols a { color: var(--text); }
.footer-cols a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: var(--s4); color: var(--muted); }
.footer-bottom p { margin: 0 0 var(--s1); }

.ad-slot:empty { display: none; }

.mobile-only { display: block; }

@media (min-width: 40rem) {
  .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .choice { gap: var(--s2); font-size: var(--fs-sm); }
  .author-photo { width: 96px; height: 96px; }
  .author-initials { font-size: 2rem; }
  h1 { font-size: 2.125rem; }
  .calc-form, .result-card { padding: var(--s5); }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 2.5rem; }
  .footer-cols { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 64rem) {
  .calc-grid { grid-template-columns: minmax(0, 55fr) minmax(0, 45fr); gap: var(--s6); }
  .result-card { position: sticky; top: var(--s5); }
  .mobile-only { display: none; }
  .card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .tool-grid { grid-template-columns: repeat(3, 1fr); }
  .why-list { grid-template-columns: repeat(3, 1fr); gap: var(--s6); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::details-content { transition: none !important; }
}

@media print {
  .no-print, .site-header, .calc-form, .faq-section, .related-section, .breadcrumb, .footer-cols { display: none !important; }
  body { background: #fff; color: #000; }
  .result-card { box-shadow: none; border: 1px solid #ccc; background: #fff; }
  .calc-grid { display: block; }
  .site-footer { background: #fff; border: 0; padding: 0; }
  a { color: #000; }
}
