/* ==========================================================================
   Cash Trust Malaysia — Design Tokens & Responsive Stylesheet
   Governed under the Trust Companies Act 1949
   ========================================================================== */

:root {
  /* Brand Palette - Charcoal, Copper, Cream */
  --color-primary: #000000;
  --color-primary-container: #1c1b1b;
  --color-on-primary: #ffffff;
  --color-primary-fixed: #e5e2e1;
  --color-primary-fixed-dim: #c8c6c5;
  --color-on-primary-fixed: #1c1b1b;
  --color-on-primary-fixed-variant: #474746;
  --color-on-primary-container: #858383;
  --color-inverse-primary: #c8c6c5;
  --color-inverse-surface: #303030;
  --color-inverse-on-surface: #f2f0f0;

  /* Copper Accents (Warm Fiduciary Warmth) */
  --color-secondary: #775928;
  --color-secondary-container: #ffd79b;
  --color-secondary-fixed: #ffdeae;
  --color-secondary-fixed-dim: #e8c086;
  --color-on-secondary: #ffffff;
  --color-on-secondary-container: #7a5c2b;
  --color-on-secondary-fixed: #281800;
  --color-on-secondary-fixed-variant: #5d4213;

  /* Cream & Neutral Surfaces */
  --color-background: #fbf9f8;
  --color-surface: #fbf9f8;
  --color-surface-bright: #fbf9f8;
  --color-surface-dim: #dbd9d9;
  --color-surface-container-lowest: #ffffff;
  --color-surface-container-low: #f5f3f3;
  --color-surface-container: #efeded;
  --color-surface-container-high: #eae8e7;
  --color-surface-container-highest: #e4e2e2;
  --color-surface-variant: #e4e2e2;
  --color-surface-tint: #5f5e5e;

  /* Typography & Contrast Colors */
  --color-on-background: #1b1c1c;
  --color-on-surface: #1b1c1c;
  --color-on-surface-variant: #444748;
  --color-outline: #747878;
  --color-outline-variant: #c4c7c7;

  /* Error & Alerts */
  --color-error: #ba1a1a;
  --color-error-container: #ffdad6;
  --color-on-error: #ffffff;
  --color-on-error-container: #93000a;

  /* Spacing Scale */
  --spacing-gutter: 24px;
  --spacing-section-padding: 100px;
  --spacing-margin-desktop: 64px;
  --spacing-margin-mobile: 20px;
  --spacing-unit: 8px;

  /* Typography Stacks */
  --font-serif: "Fraunces", "Libre Caslon Text", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Box-Sizing & Viewport Protection */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-family: var(--font-sans);
  background-color: var(--color-background);
  color: var(--color-on-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
  background-color: var(--color-background);
  color: var(--color-on-surface);
  line-height: 1.6;
  font-size: 16px;
}

main {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Distinctive Restrained Serif for All Headings */
h1, h2, h3, h4, h5, h6,
.font-serif,
.font-headline-lg,
.font-headline-lg-mobile,
.font-headline-md,
.font-display-lg,
.font-display-md,
.font-index-numeral {
  font-family: var(--font-serif);
  letter-spacing: -0.015em;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* Hairline Borders & Structural Rules (Stitch Design System) */
.hairline {
  border-bottom: 1px solid rgba(27, 28, 28, 0.12);
}

.hairline-copper {
  border-bottom: 1px solid var(--color-secondary);
}

.hairline-vertical {
  border-left: 1px solid rgba(27, 28, 28, 0.12);
}

.hairline-border {
  border-color: rgba(28, 27, 27, 0.12);
}

.hairline-border-copper {
  border-color: var(--color-secondary);
}

/* Header & Nav */
header.site-header {
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

header.site-header.scrolled {
  background-color: rgba(251, 249, 248, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

/* Hero Editorial Half-Width Backdrop */
#hero {
  position: relative;
  overflow: hidden;
}

.hero-image-layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.hero-image-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center right;
  opacity: 0.65;
  filter: contrast(1.1) brightness(0.9) saturate(0.85);
  mix-blend-mode: multiply;
}

@media (min-width: 1024px) {
  .hero-image-layer {
    width: 48%;
    /* Smooth CSS mask feathering on left edge into cream background */
    -webkit-mask-image: linear-gradient(to right, transparent 0%, rgba(0, 0, 0, 0.3) 15%, rgba(0, 0, 0, 0.75) 40%, #000000 100%);
    mask-image: linear-gradient(to right, transparent 0%, rgba(0, 0, 0, 0.3) 15%, rgba(0, 0, 0, 0.75) 40%, #000000 100%);
  }
}

@media (max-width: 1023px) {
  .hero-image-layer {
    opacity: 0.16;
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.05) 100%);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.05) 100%);
  }
  .hero-image-layer img {
    object-position: center top;
  }
}

/* Smooth Navigation Links */
.nav-link {
  position: relative;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.nav-link::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background-color: var(--color-secondary);
  transition: width 0.25s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* Mobile Menu Transitions */
#mobile-menu {
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.3s;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#mobile-menu.menu-closed {
  max-height: 0;
  overflow: hidden;
  transform: translateY(-10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#mobile-menu.menu-open {
  max-height: calc(100vh - 5rem);
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* FAQ Accordion Styling */
.accordion-item {
  border-bottom: 1px solid rgba(28, 27, 27, 0.12);
  transition: background-color 0.2s ease;
}

.accordion-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--color-primary);
  transition: color 0.2s ease;
  min-height: 48px;
}

@media (min-width: 640px) {
  .accordion-btn {
    padding: 1.5rem 0;
    font-size: 1.25rem;
  }
}

.accordion-btn:hover {
  color: var(--color-secondary);
}

.accordion-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  border: 1px solid rgba(28, 27, 27, 0.2);
  color: var(--color-secondary);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.accordion-item.active .accordion-icon {
  transform: rotate(45deg);
  background-color: var(--color-secondary);
  color: #ffffff;
  border-color: var(--color-secondary);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, padding 0.3s ease;
}

.accordion-item.active .accordion-content {
  max-height: 600px;
  opacity: 1;
  padding-bottom: 1.5rem;
}

/* Comparison Table Mobile & Desktop Rules (Zero-Overflow Guarantee) */
.comparison-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--color-secondary) transparent;
}

.comparison-table-wrapper::-webkit-scrollbar {
  height: 6px;
}

.comparison-table-wrapper::-webkit-scrollbar-thumb {
  background-color: rgba(119, 89, 40, 0.4);
  border-radius: 3px;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px; /* comfortably scrollable without clipping content on mobile */
}

.comparison-table th,
.comparison-table td {
  padding: 1rem 0.875rem;
  vertical-align: middle;
}

@media (min-width: 640px) {
  .comparison-table th,
  .comparison-table td {
    padding: 1.25rem 1rem;
  }
}

.comparison-table tr:hover td {
  background-color: rgba(239, 237, 237, 0.5);
}

.comparison-table td.highlight-col,
.comparison-table th.highlight-col {
  background-color: rgba(119, 89, 40, 0.05);
}

/* Material Symbols Adjustments */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

/* Button, Link & Form Accessible Touch Targets */
button, 
a.btn,
.nav-link,
#mobile-menu-toggle {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Minimum 44px Tap Targets */
.touch-target,
#mobile-menu-toggle,
.accordion-btn,
input,
select,
textarea {
  min-height: 44px;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 1px var(--color-secondary);
}

/* Section Spacing & Anchors */
.section-anchor {
  scroll-margin-top: 5.5rem;
}

/* Mobile Typography & Overflow Safeguards (~375px) */
@media (max-width: 640px) {
  .section-anchor {
    scroll-margin-top: 5rem;
  }
  
  /* Prevent horizontal word-wrap blowout */
  h1, h2, h3, p, span, a {
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
}
