/* Clean Slate — small layer on top of Oat (https://oat.ink).
   Oat styles semantic HTML; this file only adds app layout and a few app-specific pieces.
   Oat ships in CSS @layers, so plain rules here always win. */

:root {
  --tab-bar-height: 3.5rem;
  /* Only theme override: primary picks up the logo blue instead of Oat's default brown */
  --primary: light-dark(#1d5a94, #8ec5f5);
  --primary-foreground: light-dark(#fafafa, #0b1b2b);
  --secondary-foreground: light-dark(#27272a, #fafafa);
  --ring: var(--primary);
}

.narrow {
  --container-max: 48rem;
}

main.container {
  padding-block-end: var(--space-12);
}

/* ---------- App bar ---------- */

.app-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-dropdown);
  background: color-mix(in srgb, var(--background) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.app-bar-inner {
  --container-max: 48rem;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-height: 3.5rem;
}

.brand {
  font-weight: var(--font-semibold);
  font-size: var(--text-5);
  color: var(--foreground);
  margin-inline-end: auto;
}

.top-nav {
  display: none;
  gap: var(--space-1);
}

.top-nav a,
.tab-bar a {
  color: var(--muted-foreground);
  font-size: var(--text-7);
  font-weight: var(--font-medium);
}

.top-nav a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-medium);
}

.top-nav a:hover {
  color: var(--foreground);
  background: var(--accent);
}

.top-nav a[aria-current="page"],
.tab-bar a[aria-current="page"] {
  color: var(--foreground);
}

.top-nav a[aria-current="page"] {
  background: var(--accent);
}

.app-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.new-chore {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: var(--text-5);
}

.new-chore .label {
  display: none;
}

.user-menu-btn {
  padding: 0;
  border-radius: var(--radius-full);
}

.menu-heading {
  display: flex;
  flex-direction: column;
  padding: var(--space-2) var(--space-3);
}

/* Family join code in the account menu, so members can find it to invite someone */
.family-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

/* copy-button: show the idle, "copied" or "failed" label/icon for the current state */
.copy-button .when-copied,
.copy-button .when-failed,
.copy-button.copied .when-idle,
.copy-button.copy-failed .when-idle {
  display: none;
}

.copy-button.copied .when-copied,
.copy-button.copy-failed .when-failed {
  display: inline-flex;
}

button.copy-button.copy-failed {
  color: var(--danger);
}

.copy-button span {
  display: inline-flex;
  align-items: center;
}

.family-code code {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* Toasts open below the app bar, not over its account menu (Oat puts them at the top edge) */
.toast-container[data-placement^="top"] {
  top: calc(3.5rem + var(--space-4));
}

/* Mobile bottom tab bar: primary nav within thumb reach */
.tab-bar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: var(--z-dropdown);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tab-bar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--background);
  border-top: 1px solid var(--border);
}

.tab-bar a {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.tab-bar a[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: -1px;
  inset-inline: 30%;
  height: 2px;
  background: var(--primary);
  border-radius: var(--radius-full);
}

body:has(.tab-bar) main.container {
  padding-block-end: calc(var(--tab-bar-height) + var(--space-8) + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .top-nav {
    display: flex;
  }

  .brand {
    margin-inline-end: 0;
  }

  .app-bar-actions {
    margin-inline-start: auto;
  }

  .tab-bar {
    display: none;
  }

  body:has(.tab-bar) main.container {
    padding-block-end: var(--space-12);
  }

  .new-chore {
    width: auto;
    height: auto;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-7);
  }

  .new-chore .label {
    display: inline;
  }
}

/* ---------- Page structure ---------- */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block-end: var(--space-6);
}

.page-head h1,
.page-head h2 {
  margin: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-8) 0 var(--space-3);
  font-size: var(--text-5);
}

.section-title:first-child {
  margin-top: 0;
}

details + .section-title,
.stack > * + * {
  margin-top: var(--space-6);
}

summary .count {
  margin-inline-start: auto;
  padding: 0 var(--space-2);
  min-width: 1.75rem;
}

form > button[type="submit"],
.full {
  width: 100%;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.form-actions > * {
  width: 100%;
}

/* ---------- Auth / onboarding ---------- */

.auth-card {
  max-width: 26rem;
  margin: var(--space-4) auto 0;
}

.auth-card > header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-card > footer {
  text-align: center;
  margin-top: var(--space-6);
  font-size: var(--text-7);
  color: var(--muted-foreground);
}

.logo {
  width: 6rem;
  height: 6rem;
  margin-bottom: var(--space-2);
}

.hero {
  text-align: center;
  max-width: 36rem;
  margin: var(--space-8) auto 0;
}

.hero .logo {
  width: 8rem;
  height: 8rem;
}

.hero .lead {
  font-size: var(--text-5);
  color: var(--muted-foreground);
}

.hero .hstack {
  justify-content: center;
  margin-top: var(--space-8);
}

.avatar-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin: var(--space-2) 0 var(--space-4);
}

#avatar-slider {
  width: 4.5rem;
  height: 4.5rem;
}

/* ---------- Item lists (chores, rewards) ---------- */

.items {
  list-style: none;
  padding: 0;
  margin: 0;
}

details > .items,
details > .empty {
  margin: 0;
}

.items > li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  transition: opacity var(--transition);
}

.items > li + li {
  border-top: 1px solid var(--border);
}

.items > li.htmx-swapping {
  opacity: 0;
}

.items .check {
  padding-top: 0.125rem;
}

.items .check input[type="checkbox"] {
  width: 1.375rem;
  height: 1.375rem;
  border-radius: var(--radius-medium);
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-weight: var(--font-medium);
  overflow-wrap: anywhere;
}

.item-title.done {
  text-decoration: line-through;
  color: var(--muted-foreground);
}

.item-desc {
  font-size: var(--text-7);
  color: var(--muted-foreground);
  margin: var(--space-1) 0 0;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-1);
}

.item-meta .badge {
  padding-inline: var(--space-2);
}

.item-side {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.item-side form {
  margin: 0;
}

.items > li.locked .item-title {
  color: var(--muted-foreground);
}

.points {
  font-size: var(--text-7);
  font-weight: var(--font-semibold);
  color: var(--muted-foreground);
  white-space: nowrap;
}

.empty {
  padding: var(--space-4);
  color: var(--muted-foreground);
  font-size: var(--text-7);
}

.icon.ghost {
  color: var(--muted-foreground);
}

/* Oat's .icon.small is 32x20px: too small to tap. Use the 44px touch minimum on phones (below the
   768px tab-bar breakpoint) and any touch screen. */
@media (max-width: 767px), (pointer: coarse) {
  .icon.small {
    width: 2.75rem;
    height: 2.75rem;
  }
}

ot-dropdown menu[popover] button[role="menuitem"],
ot-dropdown menu[popover] a[role="menuitem"] {
  font-size: var(--text-7);
  font-weight: var(--font-normal);
  border-radius: 0;
}

ot-dropdown menu[popover] {
  padding: var(--space-1) 0;
}

ot-dropdown menu[popover] form {
  margin: 0;
}

/* ---------- Choice cards (radio buttons styled as cards) ---------- */

.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin: var(--space-1) 0 var(--space-4);
  padding: 0;
  border: 0;
}

@media (min-width: 640px) {
  .choices.four {
    grid-template-columns: repeat(4, 1fr);
  }
  .choices.three {
    grid-template-columns: repeat(3, 1fr);
  }
}

label.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-medium);
  font-weight: var(--font-normal);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

label.choice:hover {
  background: var(--faint);
}

label.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

label.choice strong {
  font-size: var(--text-6);
}

label.choice small {
  color: var(--muted-foreground);
  font-size: var(--text-8);
}

label.choice:has(input:checked) {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--background));
}

label.choice:has(input:focus-visible) {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-2) 0 var(--space-4);
}

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

@media (min-width: 640px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stats .card {
  padding: var(--space-4);
}

.stat-label {
  font-size: var(--text-7);
  color: var(--muted-foreground);
}

.stat-value {
  font-size: var(--text-2);
  font-weight: var(--font-semibold);
  line-height: 1.2;
  margin-top: var(--space-1);
}

.balance {
  text-align: right;
  line-height: 1.2;
}

.balance strong {
  font-size: var(--text-3);
}

.balance small {
  display: block;
  color: var(--muted-foreground);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.code-field {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* Unlayered display rules above would otherwise beat Oat's [hidden] */
[hidden] {
  display: none !important;
}

/* ---------- Tabs (onboarding) ---------- */

[role="tablist"].full {
  display: flex;
}

[role="tablist"].full [role="tab"] {
  flex: 1;
}

.code-field::placeholder {
  font-family: var(--font-sans);
  letter-spacing: normal;
}
