/*
 * main.css — Hand-Drawn design system.
 * Warm paper, wobbly borders, hard shadows, handwritten fonts.
 */

:root {
  /* Colors — pencil on paper */
  --bg: #fdfbf7;
  --fg: #2d2d2d;
  --muted: #e5e0d8;
  --accent: #ff4d4d;
  --accent-secondary: #2d5da1;
  --border: #2d2d2d;
  --postit: #fff9c4;
  --white: #ffffff;

  /* Typography */
  --font-heading: 'Kalam', cursive;
  --font-body: 'Patrick Hand', cursive;

  /* Wobbly border-radius */
  --r-wobbly: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --r-wobbly-md: 30px 10px 30px 10px / 10px 30px 10px 30px;
  --r-wobbly-sm: 12px 4px 12px 4px / 4px 12px 4px 12px;

  /* Hard offset shadows — NO blur */
  --shadow: 4px 4px 0px 0px #2d2d2d;
  --shadow-sm: 2px 2px 0px 0px #2d2d2d;
  --shadow-lg: 8px 8px 0px 0px #2d2d2d;
  --shadow-accent: 4px 4px 0px 0px #ff4d4d;

  /* Misc */
  --transition: 100ms ease;
  --border-w: 3px;
}

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

html {
  height: 100%;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--muted) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
  min-height: 100%;
  padding-top: env(safe-area-inset-top, 0);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent-secondary); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-style: wavy; }

/* ===== STAGE SYSTEM (start page) ===== */

.stage {
  display: none;
  position: fixed;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
  justify-content: center;
  align-items: center;
}
.stage--active { display: flex; }

.stage-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  height: 100%;
  width: 100%;
  padding: 2rem;
  gap: 2rem;
}

/* ===== START PAGE ===== */

.stage--start {
  background-color: var(--bg);
  background-image: radial-gradient(var(--muted) 1px, transparent 1px);
  background-size: 24px 24px;
}

.start-content {
  text-align: center;
  max-width: 540px;
}

.start-title {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 7vw, 4.2rem);
  font-weight: 700;
  color: var(--fg);
  transform: rotate(-2deg);
}

.start-subtitle {
  margin-top: 0.75rem;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  color: var(--fg);
  opacity: 0.6;
  transform: rotate(0.5deg);
}

/* ===== TOPBAR ===== */

.topbar {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 100;
}

/* ===== LANGUAGE SWITCHER ===== */

.lang-switcher {
  display: flex;
  gap: 0;
  border: 2px solid var(--border);
  border-radius: var(--r-wobbly-sm);
  overflow: hidden;
  background: var(--white);
}

.lang-btn {
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 400;
  font-family: var(--font-body);
  background: transparent;
  color: var(--fg);
  opacity: 0.5;
  transition: all var(--transition);
  border-right: 2px solid var(--border);
}
.lang-btn:last-child { border-right: none; }

.lang-btn:hover { opacity: 1; background: var(--muted); }

.lang-btn.active {
  background: var(--fg);
  color: var(--white);
  opacity: 1;
}

/* ===== BUTTONS ===== */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.85rem 1.8rem;
  border: var(--border-w) solid var(--border);
  border-radius: var(--r-wobbly);
  background: var(--white);
  color: var(--fg);
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
  white-space: nowrap;
  user-select: none;
}

.button:hover {
  background: var(--accent);
  color: var(--white);
  box-shadow: var(--shadow-sm);
  transform: translate(2px, 2px);
}

.button:active {
  box-shadow: none;
  transform: translate(4px, 4px);
}

.button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow);
}
.button:disabled:hover {
  background: var(--white);
  color: var(--fg);
}

/* Variants */
.button--primary {
  background: var(--accent);
  color: var(--white);
  box-shadow: var(--shadow);
}
.button--primary:hover {
  background: #e63e3e;
  box-shadow: var(--shadow-sm);
}

.button--secondary {
  background: var(--muted);
  color: var(--fg);
}
.button--secondary:hover {
  background: var(--accent-secondary);
  color: var(--white);
}

.button--ghost {
  background: transparent;
  box-shadow: none;
  border-style: dashed;
}
.button--ghost:hover {
  background: var(--muted);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
  border-style: solid;
}
.button--ghost:disabled:hover {
  background: transparent;
  box-shadow: none;
  border-style: dashed;
}

.button--lg {
  padding: 1.1rem 2.8rem;
  font-size: 1.35rem;
}

.button--sm {
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
}

/* ===== BUTTONBAR ===== */

.buttonbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.buttonbar--result {
  gap: 1rem;
  margin-top: 1rem;
}

/* ===== COLOR SWATCHES ===== */

.color-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 3px;
  background: transparent;
  border: var(--border-w) solid transparent;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-btn:hover {
  transform: scale(1.15) rotate(5deg);
}

.color-btn.active {
  border-color: var(--accent);
}

.color-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--border);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 480px) {
  body { font-size: 16px; }
  .stage-inner { padding: 1.25rem; gap: 1.5rem; }
  .button--lg {
    padding: 1rem 2.2rem; font-size: 1.2rem;
    min-height: 52px; width: 80%;
  }
  .topbar { top: 0.75rem; right: 0.75rem; }
  .start-title { font-size: clamp(2rem, 10vw, 3rem); }
  .start-subtitle { font-size: 0.95rem; padding: 0 0.5rem; }
  .lang-btn { padding: 8px 16px; font-size: 13px; min-height: 40px; }
  .color-btn { width: 44px; height: 44px; }
}
