/* theailand-voy — iOS (Apple) style · minimal · light + dark · mobile-first */

:root {
  color-scheme: light;
  --font-heading: "Anuphan", -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --font-body: "Sarabun", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;

  /* iOS system grays (light) */
  --bg: #f2f2f7;            /* systemGroupedBackground */
  --surface: #ffffff;       /* card */
  --ink: #1c1c1e;           /* label */
  --muted: #8a8a8e;         /* secondaryLabel */
  --line: #e3e3e8;          /* separator */
  --track: #e9e9eb;         /* segmented track */
  --primary: #2d7d9c;       /* brand tint (teal) */
  --primary-strong: #1f5f78;
  --danger: #ff3b30;        /* systemRed */
  --shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.05);
  --shadow-seg: 0 1px 3px rgba(0,0,0,0.12), 0 1px 1px rgba(0,0,0,0.04);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1c1c1e;
  --ink: #f2f2f7;
  --muted: #98989f;
  --line: #38383a;
  --track: #2c2c2e;
  --primary: #5cc4e6;
  --primary-strong: #8ad7f0;
  --danger: #ff453a;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
  --shadow-seg: 0 1px 3px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

h1, h2, .tagline, .segment-btn { font-family: var(--font-heading); }

.wrap { width: 100%; max-width: 600px; margin: 0 auto; padding: 0 16px; }

/* ===== Header (iOS translucent nav bar) ===== */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 12px;             /* iOS app-icon squircle-ish */
  background: linear-gradient(160deg, var(--primary), var(--primary-strong));
  color: #fff; font-family: var(--font-heading); font-weight: 700; font-size: 1.25rem;
  box-shadow: var(--shadow-card);
}
.brand h1 { margin: 0; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.tagline { margin: 1px 0 0; color: var(--muted); font-size: 0.8rem; font-weight: 500; }

.header-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* iOS UISegmentedControl */
.segmented {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--track); border-radius: 9px;
}
.segment-btn {
  border: 0; background: transparent; color: var(--ink);
  padding: 0.34rem 0.8rem; border-radius: 7px;
  font-size: 0.9rem; font-weight: 600; line-height: 1.2; white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.segment-btn:not(.is-active) { color: var(--muted); }
.segment-btn.is-active {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-seg);
}

/* iOS round icon button */
.theme-toggle {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 999px; background: var(--track); color: var(--primary);
  font-size: 1.1rem; transition: background 0.2s ease, transform 0.1s ease;
}
.theme-toggle:active { transform: scale(0.94); }
.theme-sun { display: none; }
html[data-theme="dark"] .theme-moon { display: none; }
html[data-theme="dark"] .theme-sun { display: inline; }

/* ===== Main ===== */
main { padding: 22px 0 56px; }

.panel {
  background: var(--surface);
  border-radius: 18px;             /* iOS grouped card */
  box-shadow: var(--shadow-card);
}
.composer { padding: 18px; }

#text {
  width: 100%; min-height: 240px; resize: vertical;
  border: 0; border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 4%, var(--surface));
  color: var(--ink); padding: 14px 15px;
  font-size: 1.0625rem; line-height: 1.6;
  outline: 2px solid transparent; transition: outline-color 0.15s ease;
}
#text::placeholder { color: var(--muted); }
#text:focus { outline-color: var(--primary); }

.counter { margin: 12px 4px 0; font-size: 0.9rem; color: var(--muted); }
.counter.is-over { color: var(--danger); font-weight: 600; }

.generate-row { margin-top: 16px; }

/* iOS filled button */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 14px; padding: 0.95rem 1.4rem;
  font-family: var(--font-heading); font-size: 1.06rem; font-weight: 600; line-height: 1;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.985); opacity: 0.85; }
.btn:disabled { opacity: 0.4; transform: none; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-ghost { background: transparent; color: var(--primary); font-weight: 600; }

/* ===== Footer ===== */
.site-footer { padding: 22px 0 40px; text-align: center; color: var(--muted); font-size: 0.8rem; }
.site-footer p { margin: 0; }

/* ===== Overlay (กำลังสร้าง) — iOS material ===== */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.overlay[hidden] { display: none; }
.overlay p { margin: 0; font-family: var(--font-heading); font-weight: 600; font-size: 1.1rem; color: var(--ink); }
.eq { display: flex; align-items: flex-end; gap: 7px; height: 60px; }
.eq span {
  width: 9px; border-radius: 999px;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  animation: eq 1s ease-in-out infinite;
}
.eq span:nth-child(2) { animation-delay: .15s; }
.eq span:nth-child(3) { animation-delay: .3s; }
.eq span:nth-child(4) { animation-delay: .45s; }
.eq span:nth-child(5) { animation-delay: .6s; }
@keyframes eq { 0%, 100% { height: 14px; } 50% { height: 60px; } }

/* ===== Modal (iOS sheet/alert) ===== */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
  background: rgba(0,0,0,0.4);
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 460px;
  background: var(--surface); border-radius: 22px;
  padding: 24px 22px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 40px rgba(0,0,0,0.25);
  text-align: center;
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes sheet-up { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-card h2 { margin: 0 0 6px; font-size: 1.3rem; font-weight: 700; }
.modal-card .sub { margin: 0 0 16px; color: var(--muted); font-size: 0.92rem; }
.modal-card audio { width: 100%; margin-bottom: 16px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }
.modal-card.err h2 { color: var(--danger); }

/* center the sheet on larger screens */
@media (min-width: 520px) {
  .modal { align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
