/*
 * Plop Marketing Site - Core CSS
 * Design system matching Flutter app's Avocado theme
 */

/* ==========================================================================
   CSS Reset & Base
   ========================================================================== */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent flash of untranslated content and flash of wrong-font text (FOUC):
   mask the whole page, not just [data-i18n] elements — static content like
   the legal pages' policy body text isn't translated via data-i18n but
   still uses language-specific fonts, so it needs the same gate. */
html:not(.i18n-ready) body {
  visibility: hidden;
}

html.i18n-ready body {
  visibility: visible;
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-background);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

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

input, button, textarea, select {
  font: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

/* ==========================================================================
   CSS Variables - Matching Flutter App Theme
   ========================================================================== */

:root {
  /* === Colors - Avocado Theme (from color_styles.dart) === */
  --color-primary: #91C7B1;           /* Soft mint green - backgrounds/decorations */
  --color-primary-dark: #6BA88F;      /* Darkened for text (4.5:1 contrast) */
  --color-text: #756D54;              /* Warm brown */
  --color-text-light: #9A8F7A;        /* Lighter text for secondary content */
  --color-background: #F6F3EA;        /* Off-white */
  --color-accent: #f4da71;            /* Soft gold */
  --color-secondary: #e9f4ef;         /* Light mint */
  --color-error: #B33951;             /* Muted burgundy */

  /* Additional UI colors */
  --color-white: #ffffff;
  --color-border: #d4d0c8;
  --color-shadow: rgba(117, 109, 84, 0.1);
  --color-overlay: rgba(35, 35, 34, 0.7);

  /* === Typography === */
  --font-title: 'Nova Cut', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-nav: 'Nova Cut', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-headline: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-section-title: 'PT Mono', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-button: 'Righteous', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'PT Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-label: 'Numans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Font sizes - responsive with clamp */
  --font-size-h1: clamp(31px, 5vw, 48px);
  --font-size-h2: clamp(26px, 4vw, 36px);
  --font-size-h3: clamp(22px, 3vw, 28px);
  --font-size-button: 22px;
  --font-size-body: clamp(16px, 2vw, 18px);
  --font-size-small: clamp(14px, 1.5vw, 16px);
  --font-size-tiny: 12px;

  /* Line heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.8;

  /* === Spacing (from layout_constants.dart) === */
  --space-xs: 3px;
  --space-sm: 4px;
  --space-md: 5px;
  --space-normal: 8px;
  --space-lg: 10px;
  --space-xl: 20px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --space-4xl: 64px;

  /* === Layout === */
  --container-max: 1200px;
  --container-narrow: 800px;
  --container-padding: var(--space-xl);

  /* === Borders & Radius === */
  --border-width: 3px;
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  --border-radius-full: 9999px;

  /* === Shadows === */
  --shadow-sm: 0 1px 2px 0 var(--color-shadow);
  --shadow-md: 0 4px 6px -1px var(--color-shadow), 0 2px 4px -1px rgba(117, 109, 84, 0.06);
  --shadow-lg: 0 10px 15px -3px var(--color-shadow), 0 4px 6px -2px rgba(117, 109, 84, 0.05);
  --shadow-xl: 0 20px 25px -5px var(--color-shadow), 0 10px 10px -5px rgba(117, 109, 84, 0.04);

  /* === Transitions === */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* === Z-index layers === */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;
}

/* Language-specific font overrides */
@font-face {
  font-family: "CJK";
  src: url("../fonts/zh/cjk.subset.woff2") format("woff2");
  unicode-range: U+4E00-9FFF, U+3000-303F;
  font-display: swap;
}
@font-face {
  font-family: "SmileySans";
  src: url("../fonts/zh/smileySans.subset.woff2") format("woff2");
  unicode-range: U+4E00-9FFF, U+3000-303F;
  font-display: swap;
}
@font-face {
  font-family: "Maoken";
  src: url("../fonts/zh/maoken.subset.woff2") format("woff2");
  unicode-range: U+4E00-9FFF, U+3000-303F;
  font-display: swap;
}
@font-face {
  font-family: "ResourceHanRounded";
  src: url("../fonts/zh/resource-han-rounded.subset.woff2") format("woff2");
  unicode-range: U+4E00-9FFF, U+3000-303F;
  font-display: swap;
}
@font-face {
  font-family: "Yshi";
  src: url("../fonts/zh/yshi.subset.woff2") format("woff2");
  unicode-range: U+4E00-9FFF, U+3000-303F;
  font-display: swap;
}

:lang(zh) {
  --font-title: 'Nova Cut', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-nav: 'ZCOOL XiaoWei', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-section-title: 'CJK', 'PT Mono', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-label: 'SmileySans', 'Numans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-body: 'ResourceHanRounded', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-headline: 'Yshi', 'Noto Sans SC', 'PingFang SC', sans-serif;
  --font-button: 'Maoken', 'Righteous', 'PingFang SC', sans-serif;
}

:lang(ja) {
  --font-title: 'Nova Cut', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-nav: 'New Tegomin', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-section-title: 'Yusei Magic', 'PT Mono', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-label: 'Zen Maru Gothic', 'Numans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-body: 'Klee One', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  --font-headline: 'Shippori Mincho B1', 'Hiragino Sans', sans-serif;
  --font-button: 'Kaisei Decol', 'Righteous', 'PingFang SC', sans-serif;
}

/* ==========================================================================
   Typography Utilities
   ========================================================================== */

h1, .h1 {
  font-family: var(--font-headline);
  font-size: var(--font-size-h1);
  font-weight: 700;
  line-height: var(--line-height-tight);
  color: var(--color-text);
  margin-bottom: var(--space-xl);
}

h2, .h2 {
  font-family: var(--font-headline);
  font-size: var(--font-size-h2);
  font-weight: 600;
  line-height: var(--line-height-tight);
  color: var(--color-text);
  margin-bottom: var(--space-lg);
}

h3, .h3 {
  font-family: var(--font-headline);
  font-size: var(--font-size-h3);
  font-weight: 600;
  line-height: var(--line-height-normal);
  color: var(--color-text);
  margin-bottom: var(--space-normal);
}

p {
  margin-bottom: var(--space-lg);
}

a {
  color: var(--color-primary-dark);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary-dark);
  outline-offset: 2px;
  border-radius: 2px;
}

strong, b {
  font-weight: 700;
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--font-size-small);
}

/* ==========================================================================
   Layout Utilities
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.container-narrow {
  max-width: var(--container-narrow);
}

.content-container {
  max-width: 70%;
  margin: 0 auto;
}

.section {
  padding-top: var(--space-4xl);
  padding-bottom: var(--space-4xl);
}

@media (max-width: 768px) {
  .section {
    padding-top: var(--space-3xl);
    padding-bottom: var(--space-3xl);
  }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-120%);
  transition: transform var(--transition-fast);
  background: var(--color-primary-dark);
  color: var(--color-white);
  padding: var(--space-normal) var(--space-lg);
  text-decoration: none;
  z-index: var(--z-tooltip);
}

.skip-link:focus {
  transform: translateY(0);
}

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

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--color-primary-dark);
  outline-offset: 2px;
}

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

/* Text alignment */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Colors */
.text-primary { color: var(--color-primary-dark); }
.text-accent { color: var(--color-accent); }
.bg-primary { background-color: var(--color-primary); }
.bg-secondary { background-color: var(--color-secondary); }
.bg-white { background-color: var(--color-white); }

/* Display */
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* Flex utilities */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: var(--space-sm); }
.gap-normal { gap: var(--space-normal); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }
.gap-2xl { gap: var(--space-2xl); }

/* Spacing */
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-normal { margin-bottom: var(--space-normal); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }
.mb-3xl { margin-bottom: var(--space-3xl); }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-normal { margin-top: var(--space-normal); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 1024px) {
  :root {
    --container-padding: var(--space-lg);
  }
}

@media (max-width: 768px) {
  :root {
    --container-padding: var(--space-normal);
    --font-size-button: 18px;
  }

  h1, .h1 {
    margin-bottom: var(--space-lg);
  }
}

@media (max-width: 480px) {
  :root {
    --space-3xl: 32px;
    --space-4xl: 48px;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  img {
    page-break-inside: avoid;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}
