/* Base styles shared by every page: fonts, theme tokens, base elements, buttons, app bar / brand / theme toggle,
   home nav (also used by /packages) and footer. Pages: base.css first, then styles.css (app) or packages.css. */

/* ===== Fonts (self-hosted, variable weight) ===== */
@font-face {
  font-family: 'Anuphan';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/anuphan-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: 'Anuphan';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/anuphan-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/space-grotesk-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2212;
}

/* ===== Theme tokens ===== */
:root {
  color-scheme: light;

  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #EEF0F3;
  --line: #E2E5EA;
  --text: #1D1F24;
  --muted: #5F6470;

  --accent: #4E7A2A;
  --accent-hover: #436A23;
  --on-accent: #FFFFFF;
  --accent-soft: #E4EFD6;
  --accent-text: #3F6620;

  --danger: #B4232C;
  --danger-soft: #FBE9EA;
  --warning-text: #8A5300;
  --warning-soft: #FFF4DB;
  --success: #2F8A4C;
  --info-text: #2D5F9A;
  --info-soft: #E3EDF9;

  --cam: #1A1C21;
  --cam-accent: #CFE8A0;
  --cam-ring: rgba(207, 232, 160, 0.45);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 2px 6px rgba(16, 24, 40, 0.06), 0 20px 48px rgba(16, 24, 40, 0.14);

  --radius: 14px;
  --radius-lg: 22px;
  --font: 'Anuphan', system-ui, sans-serif;
  --font-num: 'Space Grotesk', 'Anuphan', system-ui, sans-serif;

  /* Names used by inline styles in the page scripts */
  --text-primary: var(--text);
  --text-secondary: var(--muted);
  --primary-color: var(--accent);
  --border: var(--line);
  --background: var(--bg);
  --bg-secondary: var(--surface-2);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #16171B;
  --surface: #1F2026;
  --surface-2: #2A2B32;
  --line: rgba(255, 255, 255, 0.09);
  --text: #E7E8EC;
  --muted: #A3A6B0;

  --accent: #B5D46A;
  --accent-hover: #C3DE80;
  --on-accent: #16171B;
  --accent-soft: rgba(181, 212, 106, 0.16);
  --accent-text: #B5D46A;

  --danger: #F08A8A;
  --danger-soft: rgba(240, 138, 138, 0.13);
  --warning-text: #F2C46B;
  --warning-soft: rgba(242, 196, 107, 0.12);
  --success: #3E9E5C;
  --info-text: #8DB8EC;
  --info-soft: rgba(141, 184, 236, 0.14);

  --cam: #111215;
  --cam-accent: #B5D46A;
  --cam-ring: rgba(181, 212, 106, 0.4);

  --shadow-sm: none;
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: var(--font);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
}

a {
  color: var(--accent-text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* Form controls */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}

/* แอตทริบิวต์ hidden ต้องชนะ display ของคลาส (เช่น .btn ที่เป็น inline-flex) */
[hidden] {
  display: none !important;
}

/* ===== Buttons ===== */
.btn {
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--danger);
}

.btn-success {
  background: var(--accent);
  color: var(--on-accent);
  width: 100%;
  margin-bottom: 8px;
}

.btn-success:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-action {
  min-height: 52px;
  padding: 12px 28px;
  font-size: 16px;
}

.btn-small {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 10px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-left: 4px;
  white-space: nowrap;
}

.btn-primary kbd {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  color: inherit;
}

:root[data-theme="dark"] .btn-primary kbd {
  background: rgba(0, 0, 0, 0.12);
  border-color: rgba(0, 0, 0, 0.2);
}

/* ===== App bar, brand, stepper, theme toggle ===== */
.app-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 68px;
  padding: 10px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 18px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.brand-text small {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.brand-text strong {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-name {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 18px;
}

.brand-name span {
  color: var(--muted);
  font-weight: 500;
}

.stepper {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  font-size: 14px;
}

.stepper li {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.stepper li.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.stepper li.is-done {
  color: var(--accent-text);
  border-color: var(--accent-soft);
  background: var(--accent-soft);
}

.app-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.stepper + .app-bar-actions {
  margin-left: 0;
}

.theme-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}

.theme-toggle:hover {
  background: var(--surface-2);
}

.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

.eyebrow {
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* ===== Home ===== */
.page-home .container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 56px;
}

.home-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.home-nav-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 15px;
}

.home-nav-links a {
  color: var(--muted);
  text-decoration: none;
}

.home-nav-links a:hover {
  color: var(--text);
}

.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 56px;
  padding: 48px 0;
}

.hero-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
}

.hero-badge {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.welcome-screen h1 {
  font-size: clamp(44px, 6.2vw, 84px);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.welcome-screen h1 em {
  font-style: normal;
  color: var(--accent-text);
}

.subtitle {
  max-width: 520px;
  font-size: 19px;
  color: var(--muted);
}

.button-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.welcome-screen .button-group .btn {
  min-height: 56px;
  padding: 12px 28px;
  font-size: 17px;
}

.hero-stats {
  display: flex;
  gap: 40px;
  margin-top: 12px;
}

.hero-stats div {
  display: flex;
  flex-direction: column;
}

.hero-stats strong {
  font-family: var(--font-num);
  font-size: 30px;
  line-height: 1.2;
}

.hero-stats span {
  font-size: 14px;
  color: var(--muted);
}

.hero-visual {
  position: relative;
  width: 460px;
  height: 560px;
  flex-shrink: 0;
}

.hero-strip {
  position: absolute;
  width: 170px;
  height: 510px;
  padding: 11px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.hero-strip span {
  flex: 1;
  border-radius: 8px;
  background: var(--surface-2);
}

.hero-strip-1 {
  left: 30px;
  top: 40px;
  transform: rotate(-6deg);
}

.hero-strip-2 {
  left: 230px;
  top: 0;
  transform: rotate(5deg);
  background: var(--accent-soft);
}

.hero-strip-2 span {
  background: var(--surface);
  opacity: 0.7;
}

.info-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.info-box li {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
}

.info-note {
  max-width: 560px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 15px;
}

/* ===== Footer ===== */
.app-footer {
  padding: 20px 16px;
  margin-top: 32px;
  border-top: 1px solid var(--line);
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-logo img {
  display: block;
  width: 44px;
  height: auto;
  opacity: 0.7;
}

:root[data-theme="dark"] .footer-logo img {
  filter: invert(1);
}

.footer-text {
  color: var(--muted);
  font-size: 13px;
}

.footer-text a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.footer-text a:hover {
  color: var(--accent-text);
}

.footer-social {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.social-link {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, color 0.15s;
}

.social-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.social-link svg {
  width: 15px;
  height: 15px;
}

.page-home .app-footer {
  margin-top: 0;
  padding: 20px 0 0;
}

.page-capture .app-footer {
  margin: 0 28px;
}

/* Phones (moved from the responsive section of styles.css) */
@media (max-width: 768px) {
  .home-nav-links {
    gap: 16px;
    font-size: 14px;
  }

  .footer-social {
    margin-left: 0;
  }
}
