/* Mobile-first styles for the Breakfast Menu PWA. */
/* Single-column, mobile-first layouts for the gate, parent, and child views
   with large tap targets for suggestion selection (task 14.1, Req 9.3), built
   on a warm, calm breakfast-y palette with soft white cards. */

:root {
  /* Warm accent scale built around the original #ffb703. */
  --color-accent: #ffb703;
  --color-accent-dark: #e09600;
  --color-accent-deep: #b26a00;
  --color-accent-soft: #fff3d4;

  /* Surfaces and text. */
  --color-bg: #fffdf7;
  --color-bg-tint: #fff7e8;
  --color-surface: #ffffff;
  --color-text: #2b2119;
  --color-heading: #5a3d10;
  --color-muted: #7a6a58;
  --color-border: #ece3d2;
  --color-border-strong: #ddd0b8;

  /* Feedback colors. */
  --color-error: #b3261e;
  --color-success: #1f7a3d;
  --color-success-bg: #e7f5ec;
  --color-focus: #0a6ebd;

  --radius: 14px;
  --radius-lg: 20px;
  --tap-min: 48px;
  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --font-base: 16px;

  --shadow-card: 0 1px 2px rgba(90, 61, 16, 0.06),
    0 6px 18px rgba(90, 61, 16, 0.08);
  --shadow-card-hover: 0 2px 4px rgba(90, 61, 16, 0.08),
    0 10px 26px rgba(90, 61, 16, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: var(--font-base);
  line-height: 1.55;
  background: var(--color-bg);
  background-image: radial-gradient(
      1200px 600px at 50% -10%,
      var(--color-bg-tint),
      transparent 70%
    );
  background-attachment: fixed;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------------------------------------------------------------------------
   App shell / layout
   Mobile-first: a single centered column that fills narrow screens and caps
   its width on larger viewports.
--------------------------------------------------------------------------- */

#app {
  display: block;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-5);
}

.view,
.gate-view,
.parent-view,
.child-view {
  display: block;
}

.parent-view-inner,
.child-view-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--color-heading);
  margin: 0 0 var(--space-2);
}

h2 {
  font-size: 1.2rem;
  letter-spacing: -0.005em;
  color: var(--color-heading);
  margin: 0 0 var(--space-1);
}

legend {
  font-weight: 700;
  padding: 0 var(--space-1);
  color: var(--color-heading);
  font-size: 1rem;
}

/* Respect the [hidden] attribute set by the view modules. */
[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------------------
   Buttons: large tap targets and distinct primary / secondary variants.
--------------------------------------------------------------------------- */

button {
  font: inherit;
  font-weight: 600;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary: filled accent gradient. Deep-brown text for strong contrast. */
.primary {
  background: linear-gradient(
    180deg,
    var(--color-accent) 0%,
    var(--color-accent-dark) 100%
  );
  border-color: var(--color-accent-dark);
  color: #3a2600;
  box-shadow: 0 2px 6px rgba(224, 150, 0, 0.35);
}

.primary:not(:disabled):hover {
  background: var(--color-accent-dark);
  box-shadow: 0 4px 12px rgba(224, 150, 0, 0.4);
}

.primary:not(:disabled):active {
  box-shadow: 0 1px 3px rgba(224, 150, 0, 0.35);
}

/* Secondary: outlined, low-emphasis. */
.secondary {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-heading);
}

.secondary:not(:disabled):hover {
  border-color: var(--color-accent-dark);
  background: var(--color-accent-soft);
}

/* Accessible focus ring for keyboard users. */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Action rows stack full-width on narrow screens for easy tapping. */
.actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.actions button {
  width: 100%;
}

/* ---------------------------------------------------------------------------
   Gate view (renderGate in app.js): a centered card.
--------------------------------------------------------------------------- */

.gate-view {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 70vh;
  justify-content: center;
}

.gate-view h1 {
  text-align: center;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
}

.gate-form label {
  font-weight: 700;
  color: var(--color-heading);
}

.gate-form input {
  font: inherit;
  font-size: 1rem;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  width: 100%;
}

.gate-form input:focus-visible {
  border-color: var(--color-focus);
  background: var(--color-surface);
}

.gate-form button {
  width: 100%;
}

.gate-error {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: #fdecea;
  color: var(--color-error);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Parent view (parent-view.js): cards with clear section separation.
--------------------------------------------------------------------------- */

.parent-selection {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
}

.selection-text {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-heading);
}

.selection-text.no-selection {
  font-weight: 400;
  font-style: italic;
  color: var(--color-muted);
}

.menu-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.menu-editor fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

/* Single-column list of suggestion rows. */
.suggestion-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.suggestion-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
}

.row-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-heading);
}

/* Textareas: full width, >=16px to avoid iOS zoom, comfortable line-height. */
.suggestion-input {
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  width: 100%;
  min-height: calc(var(--tap-min) + 8px);
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  resize: vertical;
}

.suggestion-input:focus-visible {
  border-color: var(--color-focus);
}

.word-count {
  font-size: 0.85rem;
  color: var(--color-muted);
}

/* Remove button sits full-width beneath its row on mobile. */
.remove-row {
  width: 100%;
}

#parent-add-row {
  width: 100%;
}

.validation-message {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: #fdecea;
  color: var(--color-error);
  font-weight: 600;
}

.status-message {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--color-accent-soft);
  color: var(--color-accent-deep);
  font-weight: 600;
}

.status-message.error {
  background: #fdecea;
  color: var(--color-error);
}

/* ---------------------------------------------------------------------------
   Child view (child-view.js)
   Large tappable option cards; the whole card is tappable via the label.
--------------------------------------------------------------------------- */

.child-select-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.child-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Each option is a big tappable card. */
.option-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 64px;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.05s ease;
}

.option-card:hover {
  border-color: var(--color-accent-dark);
  box-shadow: var(--shadow-card-hover);
}

.option-card:active {
  transform: translateY(1px);
}

.option-input {
  width: 24px;
  height: 24px;
  min-width: 24px;
  accent-color: var(--color-accent-dark);
  margin: 0;
}

.option-text {
  font-size: 1.1rem;
  line-height: 1.4;
  color: var(--color-text);
}

/* Selected / checked state: highlight the whole card with the accent. */
.option-card:has(.option-input:checked) {
  border-color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  box-shadow: 0 0 0 3px rgba(255, 183, 3, 0.25), var(--shadow-card);
}

/* Keyboard focus reflected on the card. */
.option-card:has(.option-input:focus-visible) {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Disabled / locked visual state: clearly muted and non-interactive. */
.option-card:has(.option-input:disabled) {
  cursor: default;
  opacity: 0.7;
  background: var(--color-bg-tint);
  box-shadow: none;
}

.option-card:has(.option-input:disabled):hover {
  border-color: var(--color-border-strong);
  box-shadow: none;
}

/* The locked choice still reads as "chosen" even while disabled. */
.option-card:has(.option-input:checked:disabled) {
  opacity: 0.85;
  border-color: var(--color-accent-dark);
  background: var(--color-accent-soft);
}

.locked-banner {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--color-success-bg);
  border: 1px solid var(--color-success);
  color: var(--color-success);
  font-weight: 700;
}

.child-error {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: #fdecea;
  color: var(--color-error);
  font-weight: 600;
}

.child-status {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--color-accent-soft);
  color: var(--color-accent-deep);
  font-weight: 600;
}

.child-empty {
  margin: 0;
  padding: var(--space-5) var(--space-3);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-muted);
  font-style: italic;
  text-align: center;
}

/* ---------------------------------------------------------------------------
   Motion & color-scheme preferences
--------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }

  button:active,
  .option-card:active {
    transform: none;
  }
}
