/* Home page (/) — formal navy and indigo, with motion that stays quiet. */

:root {
  --ink: #0b1633;
  --ink-2: #13224a;
  --ink-3: #1d2f61;
  --indigo: #3b3a8f;
  --indigo-2: #5654c4;
  --scan: #7fd6ff;
  --paper: #f5f6fa;
  --white: #ffffff;
  --text: #0b1633;
  --muted: #5b6488;
  --line: rgba(11, 22, 51, 0.12);
  --line-dark: rgba(160, 190, 255, 0.18);
  --on-dark-muted: #d3d9f5;
  --on-dark-accent: #d0d6ff;

  --font-sans: "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-serif: "Noto Serif Thai", "IBM Plex Sans Thai", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --gutter: 16px;
  --header-h: 68px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

@media (min-width: 768px) {
  :root { --gutter: 32px; }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--paper);
  overflow-x: clip;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
/* Balanced lines keep short Thai words such as "ภัย" or "สภาพ" from ending up alone on a line. */
h1, h2, h3, .hero-title-th, .eyebrow { text-wrap: balance; }
p { text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--gutter); top: -60px; z-index: 100;
  background: var(--white); color: var(--ink); padding: 8px 14px; border-radius: 6px;
}
.skip-link:focus { top: 12px; }

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

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.icon {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

.muted { color: var(--muted); }

/* Thai must never be letter-spaced (vowels and tone marks drift off their consonants),
   so labels are set in the Thai sans and only their Latin parts (.en) and numbers use spaced mono. */
.eyebrow {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--muted);
}
.en, .num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.nw { white-space: nowrap; }
.sep { margin: 0 0.6em; opacity: 0.6; }

/* Section numbers count only the sections that are on the page. */
main { counter-reset: section; }
[data-section]:not(.hero) { counter-increment: section; }
.num::before {
  content: counter(section, decimal-leading-zero);
  color: var(--indigo);
  margin-right: 0.75em;
  font-weight: 500;
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 46px; padding: 0.6em 1.3em;
  border-radius: 6px; border: 1px solid transparent;
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background-color 180ms, color 180ms, border-color 180ms, transform 180ms var(--ease-out);
}
.btn:hover { transform: translateY(-1px); }
.btn-sm { min-height: 38px; padding: 0.35em 1.1em; }
.btn-primary { background: var(--indigo); color: var(--white); }
.btn-primary:hover { background: var(--indigo-2); }
.btn-outline { border-color: var(--line); color: var(--ink); background: var(--white); }
.btn-outline:hover { border-color: var(--indigo); color: var(--indigo); }
.btn-light { background: var(--white); color: var(--ink); }
.btn-light:hover { background: #e8ecff; }

.link-arrow { color: var(--muted); font-weight: 500; text-decoration: none; }
.link-arrow:hover { color: var(--indigo); }

/* Panel: a card with one chamfered corner. */
.panel {
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--line);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
  border-radius: 4px;
}
.panel-dark {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px var(--line-dark);
}

/* ---------------------------------------------------------------- Header */

.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--header-h);
  /* Transparent only at the top of the page, where it sits over the dark hero. */
  color: var(--white);
  transition: background-color 240ms, box-shadow 240ms, color 240ms;
}
.site-header.is-solid {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--line);
  color: var(--ink);
}
.header-row { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
/* The S.A.K. wordmark (logo2.png without its empty margin) names the company in the header and
   the footer. It is drawn in indigo, so it turns white on dark ground: the footer, the login page
   and the header while it is transparent over the hero. */
.brand-logo { display: block; width: auto; height: 34px; transition: filter 240ms; }
.site-header:not(.is-solid):not(.menu-open) .brand-logo,
.auth-header .brand-logo,
.brand-footer .brand-logo { filter: brightness(0) invert(1); }
/* An indigo button would vanish against the hero, so the header's one is glass until it turns solid. */
.site-header:not(.is-solid):not(.menu-open) .site-nav .btn-primary {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}
.site-header:not(.is-solid):not(.menu-open) .site-nav .btn-primary:hover { background: rgba(255, 255, 255, 0.2); }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav > a:not(.btn) {
  padding: 8px 12px; border-radius: 6px; text-decoration: none; font-weight: 500;
  opacity: 0.86; transition: opacity 160ms, background-color 160ms;
}
.site-nav > a:not(.btn):hover { opacity: 1; background: rgba(127, 140, 200, 0.14); }
.nav-divider { width: 1px; height: 22px; background: currentColor; opacity: 0.25; margin: 0 8px; }

.nav-toggle {
  display: none; background: none; border: 0; color: inherit; padding: 8px; cursor: pointer;
}
.nav-toggle .icon { width: 28px; height: 28px; }

.user-menu { position: relative; }
.user-menu summary {
  list-style: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 6px 14px; border-radius: 6px; cursor: pointer;
  background: var(--indigo); color: var(--white); font-weight: 500;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .chevron { transition: transform 200ms; }
.user-menu[open] .chevron { transform: rotate(180deg); }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 260px;
  background: var(--white); color: var(--ink);
  border-radius: 8px; box-shadow: 0 18px 50px -12px rgba(11, 22, 51, 0.35), inset 0 0 0 1px var(--line);
  overflow: hidden;
}
.user-menu-who { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; }
.user-menu-who span { color: var(--muted); font-size: 0.875rem; }
.user-menu-label { padding: 10px 16px 4px; }
.user-menu-label { font-size: 0.78rem; font-weight: 500; color: var(--muted); }
.user-menu-panel a { display: block; padding: 8px 16px; text-decoration: none; }
.user-menu-panel a:hover { background: #eef0fb; color: var(--indigo); }
.user-menu-dashboard { border-top: 1px solid var(--line); margin-top: 6px; }
.user-menu-logout {
  width: 100%; text-align: left; padding: 12px 16px; border: 0; cursor: pointer;
  background: #fbf5f6; color: #b42335; font: inherit; font-weight: 600;
}
.user-menu-logout:hover { background: #f8e3e6; }

@media (max-width: 899px) {
  .nav-toggle { display: inline-flex; }
  .brand-logo { height: 30px; }
  .site-nav {
    position: absolute; left: 0; right: 0; top: var(--header-h);
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 12px var(--gutter) 20px;
    background: var(--white); color: var(--ink);
    box-shadow: 0 18px 40px -16px rgba(11, 22, 51, 0.35);
    visibility: hidden; opacity: 0; transform: translateY(-8px);
    transition: opacity 200ms, transform 200ms var(--ease-out), visibility 0s 200ms;
  }
  .site-nav.is-open {
    visibility: visible; opacity: 1; transform: none;
    transition: opacity 200ms, transform 200ms var(--ease-out);
  }
  .site-nav > a:not(.btn) { padding: 12px 8px; }
  .nav-divider { width: auto; height: 1px; margin: 8px 0; }
  .site-nav .btn { margin-top: 4px; }
  .user-menu summary { width: 100%; justify-content: center; }
  .user-menu-panel { position: static; width: auto; margin-top: 8px; box-shadow: inset 0 0 0 1px var(--line); }
  .site-header.menu-open { background: var(--white); color: var(--ink); }
}

/* ---------------------------------------------------------------- Hero */

.hero {
  --muted: var(--on-dark-muted);
  position: relative;
  /* The hero fills the screen on every device; svh leaves room for a phone's browser bars. */
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: calc(var(--header-h) + 48px) 0 56px;
  /* The previous home page's background: near-black slate with floating dots (particles.js). */
  background: #0f172a;
  color: var(--white);
  overflow: hidden;
}
.particles { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }

/* Type alone carries the hero, set centred like the title page of a printed report. */
.hero-inner { position: relative; z-index: 1; display: grid; justify-items: center; text-align: center; }
.hero-title { display: grid; justify-items: center; gap: 18px; margin-bottom: 24px; }
.hero-brand {
  font-family: var(--font-mono);
  font-size: clamp(0.95rem, 0.8rem + 0.6vw, 1.2rem);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--on-dark-accent);
}
.hero-title-th {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2.3rem, 6vw, 4.6rem);
  line-height: 1.25;
  color: var(--white);
}
.hero-lead { max-width: 34em; color: var(--muted); font-size: 1.1rem; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 32px; }
.hero .btn-primary { background: var(--white); color: var(--ink); }
.hero .btn-primary:hover { background: #e8ecff; }
.hero .btn-outline { background: rgba(255, 255, 255, 0.04); border-color: rgba(214, 224, 255, 0.35); color: var(--white); }
.hero .btn-outline:hover { border-color: var(--white); color: var(--white); }


/* Entrance of the hero on load. */
.js .hero-in { opacity: 0; transform: translateY(18px); }
.js.is-loaded .hero-in {
  opacity: 1; transform: none;
  transition: opacity 900ms var(--ease-out), transform 900ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}

/* ---------------------------------------------------------------- Sections */

.section { padding: 112px 0; position: relative; }
.section-tint { background: #eceef6; }
.section-dark { background: var(--ink); color: var(--white); }
.section-dark .eyebrow { color: rgba(214, 224, 255, 0.65); }
.section-dark .num::before { color: var(--scan); }
.section-dark .lead { color: rgba(225, 232, 255, 0.75); }

.section-head { max-width: 640px; display: grid; gap: 14px; margin-bottom: 56px; }
.section-head-center { margin-left: auto; margin-right: auto; text-align: center; justify-items: center; }
.title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.9rem, 3.8vw, 2.9rem);
  line-height: 1.25;
}
.lead { color: var(--muted); font-size: 1.08rem; }

@media (max-width: 767px) {
  .section { padding: 80px 0; }
  .section-head { margin-bottom: 40px; }
}

/* Welcome (signed in) */
.welcome-panel { position: relative; z-index: 2; margin-top: -56px; }
.welcome-card {
  padding: 28px; display: grid; gap: 20px; align-items: center;
  box-shadow: inset 0 0 0 1px var(--line), 0 30px 60px -30px rgba(11, 22, 51, 0.45);
}
.welcome-name { font-family: var(--font-serif); font-size: clamp(1.4rem, 2.6vw, 1.9rem); line-height: 1.35; margin: 6px 0 4px; }
.welcome-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
@media (min-width: 900px) {
  .welcome-card { grid-template-columns: minmax(0, 1fr) auto; padding: 32px 36px; }
  .welcome-actions { justify-content: flex-end; max-width: 620px; }
}

/* About */
.about-grid { display: grid; gap: 48px; }
.about-note { padding: 22px 24px; margin-top: 12px; display: grid; gap: 8px; color: var(--muted); }
.about-note .eyebrow { color: var(--indigo); }
.about-note + .about-note { margin-top: 0; }
.mission-title { font-family: var(--font-serif); font-size: 1.4rem; margin-bottom: 18px; }
.mission-list { display: grid; }
.mission-list li {
  display: grid; grid-template-columns: 56px 1fr; gap: 16px;
  padding: 22px 0; border-top: 1px solid var(--line);
}
.mission-list li:last-child { border-bottom: 1px solid var(--line); }
.mission-index { font-family: var(--font-mono); color: var(--indigo); font-size: 0.95rem; padding-top: 3px; }
.mission-list h4 { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.mission-list p { color: var(--muted); }
@media (min-width: 900px) {
  .about-grid { grid-template-columns: 1fr 1fr; gap: 72px; align-items: start; }
  .about-grid .section-head { margin-bottom: 0; position: sticky; top: calc(var(--header-h) + 32px); }
}

/* Services as steps joined by a line that fills while scrolling. */
.steps { position: relative; display: grid; gap: 20px; }
.steps-line { display: none; }
.step { position: relative; padding: 28px 24px 30px; background: var(--white); border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); }
.step-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--scan);
  box-shadow: 0 0 0 6px #eceef6;
  margin-bottom: 20px;
}
.step-icon .icon { width: 26px; height: 26px; }
.step-no { font-size: 0.8rem; font-weight: 500; color: var(--indigo); margin-bottom: 6px; }
.step h3 { font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; }
.step p { color: var(--muted); }
@media (min-width: 900px) {
  .steps { grid-template-columns: repeat(3, 1fr); gap: 28px; }
  .steps-line {
    display: block; position: absolute; left: 52px; right: 52px; top: 56px; height: 2px;
    background: rgba(59, 58, 143, 0.15);
  }
  .steps-line span {
    position: absolute; inset: 0; background: linear-gradient(90deg, var(--indigo), var(--scan));
    transform-origin: left; transform: scaleX(var(--progress, 1));
  }
  .js .steps-line span { transform: scaleX(var(--progress, 0)); }
  .step { background: transparent; box-shadow: none; padding: 0 8px; }
}

/* Customers */
.customers {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}
.customer { perspective: 900px; }
.customer-card {
  --tile-bg: var(--white);
  --tile-ink: var(--muted);
  height: 168px; padding: 20px 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  text-align: center;
  background: var(--tile-bg);
  box-shadow: inset 0 0 0 1px var(--line);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
  border-radius: 4px;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 500ms var(--ease-out), box-shadow 300ms;
  will-change: transform;
}
.customer-card:hover { box-shadow: inset 0 0 0 1px rgba(59, 58, 143, 0.45); }
.customer-card.is-tilting { transition: transform 80ms linear, box-shadow 300ms; }
.customer-logo { max-height: 64px; max-width: 82%; width: auto; height: auto; object-fit: contain; }
.customer-name { font-size: 0.78rem; line-height: 1.45; color: var(--tile-ink); }
.customer-name-only {
  font-family: var(--font-serif); font-size: 1rem; font-weight: 600; line-height: 1.5; color: var(--ink);
}
/* Logos published only in white sit on their brand colour, as on the insurers' own sites. */
.customer[data-customer="bki"] .customer-card { --tile-bg: #0e1f8e; --tile-ink: rgba(255, 255, 255, 0.82); box-shadow: none; }
.customer[data-customer="tvi"] .customer-card { --tile-bg: #00a650; --tile-ink: rgba(255, 255, 255, 0.88); box-shadow: none; }
/* Phones: two columns, an odd last tile takes the full row. */
@media (max-width: 519px) {
  .customers { grid-template-columns: 1fr 1fr; gap: 12px; }
  .customer:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .customer-card { height: 148px; padding: 16px 12px; gap: 10px; }
  .customer-logo { max-height: 48px; max-width: 88%; }
  .customer-name { font-size: 0.72rem; }
}

/* Careers */
.careers-grid { display: grid; gap: 40px; align-items: center; }
.careers-grid .section-head { margin-bottom: 0; }
.careers-grid .btn { justify-self: start; margin-top: 10px; }
.perks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.perks li { display: grid; gap: 14px; padding: 22px 20px; font-weight: 500; }
.perks .icon { width: 28px; height: 28px; color: var(--scan); }
@media (min-width: 900px) {
  .careers-grid { grid-template-columns: 1.1fr 1fr; gap: 72px; }
}

/* Contact */
.contact-grid { display: grid; gap: 16px; max-width: 1080px; margin: 0 auto; }
.contact-card { display: flex; gap: 18px; padding: 26px 24px; }
.contact-card > .icon { width: 30px; height: 30px; color: var(--indigo); margin-top: 2px; }
.contact-value { font-size: 1.25rem; font-weight: 600; margin: 4px 0 2px; }
.contact-value a { text-decoration: none; }
.contact-email { font-size: 1.05rem; overflow-wrap: anywhere; }
.contact-value a:hover { color: var(--indigo); }
@media (min-width: 700px) {
  .contact-grid { grid-template-columns: 1fr 1fr; }
  .contact-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (min-width: 1024px) {
  .contact-grid { grid-template-columns: repeat(3, 1fr); }
  .contact-card:last-child:nth-child(odd) { grid-column: auto; }
}

/* Footer */
.site-footer { background: #070f26; color: rgba(225, 232, 255, 0.8); padding: 44px 0; }
.footer-row { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: space-between; }
.brand-footer { display: grid; gap: 10px; justify-items: start; }
.brand-footer .muted { color: rgba(225, 232, 255, 0.55); font-size: 0.9rem; }
.copyright { font-size: 0.85rem; color: rgba(225, 232, 255, 0.55); }

/* ---------------------------------------------------------------- Section rail */

.rail {
  position: fixed; right: 22px; top: 50%; z-index: 40;
  transform: translateY(-50%);
  display: none; flex-direction: column; align-items: flex-end; gap: 10px;
}
.rail a {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.78rem;
  color: var(--muted); text-decoration: none; opacity: 0.75;
  transition: color 200ms, opacity 200ms;
}
.rail a::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px currentColor; transition: background-color 200ms, transform 200ms;
}
.rail a span { opacity: 0; transform: translateX(6px); transition: opacity 200ms, transform 200ms; }
.rail:hover a span, .rail a.is-active span { opacity: 1; transform: none; }
.rail a.is-active { color: var(--indigo); opacity: 1; }
.rail a.is-active::after { background: currentColor; transform: scale(1.15); }
.rail.on-dark a { color: rgba(214, 224, 255, 0.7); }
.rail.on-dark a.is-active { color: var(--scan); }
/* Narrower screens would put the rail labels over the page content. */
@media (min-width: 1360px) {
  .rail { display: flex; }
}

/* ---------------------------------------------------------------- Reveal on scroll */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 800ms var(--ease-out), transform 800ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.js [data-reveal].is-visible { opacity: 1; transform: none; }
/* Tilt owns the card's transform, so the reveal moves the list item instead. */
.js .customer[data-reveal] { transform: translateY(26px) scale(0.97); }
.js .customer[data-reveal].is-visible { transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
  .js [data-reveal], .js .hero-in { opacity: 1; transform: none; }
}
