/* ============================================================
   Malzive — Atoll Atlas design system
   Shared tokens + base + reusable primitives
   ============================================================ */

:root {
  /* Color */
  --ink: #0B1F25;
  --ink-mute: #5B6B70;
  --ink-soft: #8A9498;
  --lagoon: #0B3B4A;
  --lagoon-deep: #062B36;
  --shallow: #7FB7B5;
  --shallow-soft: #C5DEDC;
  --sand: #F2E9DC;
  --paper: #FAF6EE;
  --paper-2: #F5EFE3;
  --coral: #E26B3F;
  --coral-deep: #B9482A;
  --coral-soft: #F6CFBE;
  --rule: #DDD3C0;
  --rule-strong: #A89C82;
  --surface: #FFFFFF;
  --shadow-card: 0 1px 0 rgba(11, 31, 37, 0.04), 0 8px 24px rgba(11, 31, 37, 0.06);
  --shadow-pop: 0 16px 48px rgba(11, 31, 37, 0.14);

  /* Type */
  --font-display: 'Fraunces', 'Times New Roman', serif;
  --font-ui: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;
  --s-10: 128px;

  /* Layout */
  --container: 1280px;
  --gutter: 24px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-pill: 999px;
}

/* ============================================================
   Base
   ============================================================ */

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, video { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

button { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; color: inherit; }

input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

::selection { background: var(--coral); color: white; }

/* Focus rings */
:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ============================================================
   Type primitives
   ============================================================ */

.display-xl, .display-l, .display-m, .display-s {
  font-family: var(--font-display);
  font-weight: 800;
  font-variation-settings: 'opsz' 144, 'SOFT' 50, 'WONK' 0;
  text-wrap: balance;
  margin: 0;
}
.display-xl { font-size: clamp(48px, 7vw, 84px); line-height: 0.95; letter-spacing: -0.025em; font-weight: 800; }
.display-l  { font-size: clamp(36px, 5vw, 56px); line-height: 1.0; letter-spacing: -0.02em; font-weight: 700; }
.display-m  { font-size: clamp(28px, 3.4vw, 36px); line-height: 1.1; letter-spacing: -0.015em; font-weight: 700; }
.display-s  { font-size: 24px; line-height: 1.2; letter-spacing: -0.01em; font-weight: 700; }

.h-lead {
  font-family: var(--font-ui);
  font-size: 18px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  font-weight: 500;
  color: var(--ink-mute);
  text-wrap: pretty;
  margin: 0;
}

.body { font-size: 15px; line-height: 1.55; }
.body p { text-wrap: pretty; margin: 0 0 1em 0; }

.small { font-size: 13px; line-height: 1.5; color: var(--ink-mute); }

.kicker, .micro {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.mono {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  letter-spacing: 0.02em;
}

.price {
  font-family: var(--font-display);
  font-weight: 700;
  font-variation-settings: 'opsz' 24;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  letter-spacing: -0.01em;
}

.italic-pull {
  font-family: var(--font-display);
  font-style: italic;
  font-variation-settings: 'opsz' 144, 'SOFT' 100;
  font-weight: 400;
}

/* ============================================================
   Layout primitives
   ============================================================ */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.row { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-5 { gap: 24px; } .gap-6 { gap: 32px; }
.gap-7 { gap: 48px; }

.hairline { border-top: 1px solid var(--rule); }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  transition: background 150ms cubic-bezier(0.2, 0, 0.2, 1),
              color 150ms cubic-bezier(0.2, 0, 0.2, 1),
              border-color 150ms cubic-bezier(0.2, 0, 0.2, 1);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: var(--lagoon); }

.btn-coral {
  background: var(--coral);
  color: white;
}
.btn-coral:hover { background: var(--coral-deep); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
}
.btn-ghost:hover { border-color: var(--ink); background: var(--sand); }

.btn-link {
  height: auto; padding: 0;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
}

.btn-icon {
  width: 40px; height: 40px; padding: 0;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--rule);
}
.btn-icon:hover { border-color: var(--ink); }

/* ============================================================
   Badges & chips
   ============================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--rule);
}
.chip-dark { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip-coral { background: var(--coral); color: white; border-color: var(--coral); }
.chip-shallow { background: var(--shallow-soft); color: var(--lagoon-deep); border-color: var(--shallow-soft); }
.chip-sand { background: var(--sand); color: var(--ink); border-color: var(--sand); }
.chip-outline { background: transparent; }

.dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

.badge-transfer {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--lagoon);
}
.badge-transfer .sep { color: var(--rule-strong); }

.badge-season {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--shallow-soft);
  color: var(--lagoon-deep);
}
.badge-season.in { background: var(--coral-soft); color: var(--coral-deep); }

/* ============================================================
   Card system
   ============================================================ */

.card {
  display: flex; flex-direction: column; gap: 12px;
  cursor: pointer;
  transition: transform 200ms cubic-bezier(0.2, 0, 0.2, 1);
}
.card:hover { text-decoration: none; }
.card:hover .card-photo img,
.card:hover .card-photo .ph { transform: scale(1.03); }

.card-photo {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--sand);
}
.card-photo img,
.card-photo .ph {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 400ms cubic-bezier(0.2, 0, 0.2, 1);
}
.card-photo--43 { aspect-ratio: 4 / 3; }
.card-photo--169 { aspect-ratio: 16 / 9; }
.card-photo--11 { aspect-ratio: 1 / 1; }
.card-photo--34 { aspect-ratio: 3 / 4; }

.card-heart {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
}
.card-heart:hover { color: var(--coral); }

.card-corner-badge {
  position: absolute; top: 12px; left: 12px;
  background: rgba(11, 31, 37, 0.86);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 9px;
  border-radius: 4px;
}

.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.card-vendor {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-wrap: balance;
}

.card-sub {
  font-size: 13px;
  color: var(--ink-mute);
  display: flex; align-items: center; gap: 8px;
}

.card-price {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.card-price small {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0;
}

.card-rating {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500;
}
.card-rating .star { color: var(--coral); }

.card-color-dots {
  display: inline-flex; gap: 4px;
}
.card-color-dots span {
  width: 12px; height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(11,31,37,0.15);
}

/* ============================================================
   Patterned placeholder (for missing photos)
   Specific labels: "Aerial · Baa · Hanifaru Bay"
   ============================================================ */

.ph {
  width: 100%; height: 100%;
  background: repeating-linear-gradient(45deg, var(--paper-2) 0 12px, var(--sand) 12px 24px);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--lagoon);
  text-align: center;
  padding: 12px;
}
.ph-aerial { background: repeating-linear-gradient(135deg, #C5DEDC 0 12px, #A8C8C2 12px 24px); color: var(--lagoon-deep); }
.ph-water { background: repeating-linear-gradient(60deg, #7FB7B5 0 12px, #5A9A98 12px 24px); color: var(--paper); }
.ph-life { background: repeating-linear-gradient(30deg, #F2E9DC 0 12px, #E8D9B8 12px 24px); color: var(--lagoon); }
.ph-product { background: repeating-linear-gradient(15deg, #FAF6EE 0 12px, #E8DCC0 12px 24px); color: var(--coral-deep); }
.ph .label {
  background: rgba(255,255,255,0.92);
  padding: 5px 10px;
  border: 1px solid currentColor;
  font-weight: 500;
  letter-spacing: 0.08em;
}

/* ============================================================
   Forms
   ============================================================ */

.input {
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 14px;
  width: 100%;
  transition: border-color 150ms;
}
.input:focus { outline: none; border-color: var(--ink); }

.label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: block;
  margin-bottom: 6px;
}

/* ============================================================
   Search bar (Universal)
   ============================================================ */

.usearch {
  background: var(--surface);
  border-radius: var(--radius-pill);
  border: 1px solid var(--rule);
  padding: 6px;
  display: inline-flex;
  box-shadow: var(--shadow-card);
  align-items: center;
}

.usearch-tab {
  display: flex; align-items: center; gap: 6px;
  height: 52px;
  padding: 0 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--rule);
  position: relative;
}
.usearch-tab:last-of-type { border-right: none; }
.usearch-tab small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 2px;
}

.usearch-go {
  width: 52px; height: 52px;
  border-radius: 999px;
  background: var(--coral);
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-left: 6px;
}
.usearch-go:hover { background: var(--coral-deep); }

/* ============================================================
   Header
   ============================================================ */

.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(8px);
}
.site-header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 14px var(--gutter);
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.04em;
  color: var(--ink);
  font-variation-settings: 'opsz' 144, 'SOFT' 0;
}
.logo-dot { color: var(--coral); }

.nav {
  display: flex; gap: 28px;
  font-size: 14px;
  font-weight: 500;
}
.nav a { color: var(--ink); }
.nav a:hover { color: var(--coral); text-decoration: none; }

.lang-switch {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  background: var(--lagoon-deep);
  color: var(--shallow-soft);
  padding: 64px 0 40px;
  margin-top: 96px;
}
.site-footer .container {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr;
  gap: 48px;
}
.site-footer h4 {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--shallow);
  margin: 0 0 16px 0;
}
.site-footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.site-footer a { color: var(--shallow-soft); }
.site-footer a:hover { color: white; }
.site-footer-bottom {
  max-width: var(--container);
  margin: 56px auto 0;
  padding: 24px var(--gutter) 0;
  border-top: 1px solid rgba(127, 183, 181, 0.2);
  display: flex; justify-content: space-between;
  font-size: 12px;
  color: var(--shallow);
  font-family: var(--font-mono);
}

/* ============================================================
   Section header (editorial)
   ============================================================ */

.section-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: 32px;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.section-head .kicker { display: block; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.section-head .meta { font-size: 13px; color: var(--ink-mute); white-space: nowrap; }

/* ============================================================
   Utility
   ============================================================ */

.tabular { font-feature-settings: 'tnum' 1, 'lnum' 1; }
.lining { font-feature-settings: 'lnum' 1; }
.osf { font-feature-settings: 'onum' 1; }
.balance { text-wrap: balance; }
.pretty { text-wrap: pretty; }

.scroll-x { overflow-x: auto; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }

@media (max-width: 900px) {
  .site-footer .container { grid-template-columns: 1fr 1fr; }
  .nav { display: none; }
  .usearch { flex-wrap: wrap; padding: 8px; border-radius: var(--radius-lg); }
  .usearch-tab { border-right: none; border-bottom: 1px solid var(--rule); }
  .usearch-tab:last-of-type { border-bottom: none; }
}

/* ============================================================
   Responsive — collapse to single column on phones
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --gutter: 16px;
    --s-7: 32px;
    --s-8: 48px;
    --s-9: 64px;
  }

  /* Header collapses */
  [data-screen-label="Header"] nav { display: none !important; }
  [data-screen-label="Header"] [aria-label*="MVR"],
  [data-screen-label="Header"] [aria-label*="Currency"] { display: none !important; }
  [data-screen-label="Header"] > div > div:last-child > a { display: none !important; }

  /* Two-column → single column for all main layouts */
  [data-screen-label="Browse"] main + main,
  [data-screen-label] aside + main,
  [data-screen-label] main + aside,
  [data-screen-label="Stay Detail"] main,
  [data-screen-label="Stay Detail"] aside,
  [data-screen-label="Charter Detail"] main,
  [data-screen-label="Charter Detail"] aside,
  [data-screen-label="Shop Detail"] > div,
  [data-screen-label="Trip Builder"] aside {
    grid-template-columns: 1fr !important;
  }

  /* Generic grid collapse for any inline-style two-col layouts */
  body [style*="grid-template-columns: 1fr 420px"],
  body [style*="grid-template-columns: 260px 1fr"],
  body [style*="grid-template-columns: 1fr 1fr"],
  body [style*="grid-template-columns: 5fr 7fr"],
  body [style*="grid-template-columns: 1fr 380px"],
  body [style*="grid-template-columns: 1.1fr 1fr"],
  body [style*="grid-template-columns: 1fr 7fr"],
  body [style*="gridTemplateColumns: 'repeat(4, 1fr)'"],
  body [style*="grid-template-columns: repeat(4, 1fr)"],
  body [style*="grid-template-columns: repeat(5, 1fr)"],
  body [style*="grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr"],
  body [style*="grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr"],
  body [style*="grid-template-columns: 2fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  /* Re-collapse 3-col card grids to 1-col */
  body [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* Universal search wraps */
  body [role="search"][style*="min-width"] {
    min-width: 0 !important;
    flex-direction: column !important;
    border-radius: 16px !important;
    align-items: stretch !important;
  }

  /* Hero typography */
  body [data-screen-label="Hero"] h1 { font-size: clamp(40px, 12vw, 56px) !important; }
  body [data-screen-label="Stay Detail"] h1 { font-size: clamp(32px, 10vw, 40px) !important; }

  /* Sticky sidebars unstick */
  body [style*="position: sticky"] {
    position: static !important;
  }

  /* Atoll map: drop to vertical stack */
  [data-screen-label="Atoll Map"] {
    padding: 32px 20px !important;
    grid-template-columns: 1fr !important;
  }
  [data-screen-label="Atoll Map"] svg { max-height: 360px !important; }

  /* Vendor dashboard sidebar → collapsed */
  [data-screen-label="Vendor Dashboard"] aside {
    display: none !important;
  }

  /* Footer */
  .site-footer .container { grid-template-columns: 1fr !important; gap: 32px !important; }
  .site-footer-bottom { flex-direction: column !important; gap: 8px !important; }

  /* Trip-builder leg cards stack inner contents */
  body [style*="grid-template-columns: '64px 1fr'"] {
    grid-template-columns: 32px 1fr !important;
    gap: 12px !important;
  }
}

@media (max-width: 480px) {
  body { font-size: 14px; }
  .site-footer .container { padding: 0 16px; }
}
