/* Pages outside the tabs: the login cover, the first-visit cards, and error pages. */

/*
 * The login page is the diary's cover: Yomochi on a green field with a soft sunrise, then the
 * sheet with the form pulled up over it.
 */
body.login {
  background:
    radial-gradient(60rem 28rem at 50% -6rem, color-mix(in srgb, var(--color-paper) 70%, transparent), transparent 70%),
    var(--color-hero);
}

.login main {
  position: relative;
  z-index: 1;
  min-height: 70dvh;
  padding-top: var(--space-6);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--color-bg);
  box-shadow: 0 -1rem 2.5rem -1.5rem rgb(31 42 27 / 0.25);
}

/* A grab handle on the sheet, the shape every phone user knows as "this lifts". */
.login main::before {
  content: "";
  position: absolute;
  top: var(--space-2);
  left: 50%;
  width: 2.5rem;
  height: 0.3125rem;
  border-radius: 999px;
  background: var(--color-rule);
  translate: -50% 0;
}

/* The cover stays put while scrolling, so the sheet slides up over the title. */
.login-hero {
  position: sticky;
  top: 0;
  padding: var(--space-8) 0 var(--space-6);
}

.login-hero .ui\:hero-content {
  gap: var(--space-3);
}

.login-hero .mascot {
  filter: drop-shadow(0 1rem 0.75rem rgb(31 42 27 / 0.18));
}

.login-hero h1 {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.login-hero p {
  margin: 0;
  line-height: 1.9;
}

.uses {
  margin-top: var(--space-8);
}

.uses h2 {
  margin: 0 0 var(--space-6);
  font-size: var(--font-size-md);
  text-align: center;
}

.use-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

/*
 * Each voice is a sticky note in its label's tint, held by a strip of tape and set a little
 * askew, alternating left and right like notes stuck on a fridge.
 */
.use {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-3) var(--space-3);
  border-radius: 0.25rem 0.25rem 0.25rem 1.25rem;
  background: var(--label-bg);
  box-shadow: var(--shadow-card);
  rotate: -1.5deg;
}

.use:nth-child(even) {
  rotate: 1.5deg;
  translate: 0 var(--space-3);
}

.use::before {
  content: "";
  position: absolute;
  top: -0.625rem;
  left: 50%;
  width: 3.5rem;
  height: 1.125rem;
  background: color-mix(in srgb, var(--color-paper) 70%, transparent);
  box-shadow: 0 1px 0.125rem rgb(0 0 0 / 0.08);
  translate: -50% 0;
  rotate: -4deg;
}

.use-voice {
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-xs);
  line-height: 1.75;
}

.use-name {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.use-name::before {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--label-dot);
}

.login-title {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-studio {
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.3em;
}

/* The six boxes are narrower than the form, so the field centers them under the heading. */
.code-field {
  justify-items: center;
}

.code-field .ui\:fieldset-legend {
  margin-inline: auto;
}

/* The lead belongs to the guest button, so it sits right on it, apart from the login buttons above. */
.guest-start {
  margin-block-start: var(--space-6);
}

.guest-start > p {
  margin-block-end: var(--space-2);
  font-size: var(--font-size-xs);
  text-align: center;
  text-wrap: balance;
}

/* First-visit cards: one per screen, swiped or paged with 次へ; the card in view turns face-on. */
.welcome main,
.centered main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding-block: var(--space-4);
}

.welcome-cards {
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  perspective: 60rem;
  /* welcome.js fits the height to the card in view; a taller neighbour is clipped, not scrolled. */
  overflow-y: hidden;
  transition: height 0.45s ease;
}

.welcome-card {
  scroll-margin: 0;
}

.welcome-card .ui\:card {
  width: 100%;
  gap: var(--space-3);
  transform-origin: left center;
  transition:
    transform 0.45s ease,
    opacity 0.45s ease;
}

.welcome-card h2 {
  margin: 0;
  font-size: var(--font-size-lg);
}

.welcome-card h2:focus {
  outline: none;
}

/* daisyUI grows every p in a card body; each card keeps its own height instead. */
.welcome-card p {
  flex-grow: 0;
  margin: 0;
}

.welcome-count {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.welcome-art {
  display: grid;
  place-items: center;
  min-height: 8rem;
}

.welcome-pose {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
}

.welcome-mascot-name {
  margin-block-start: calc(-1 * var(--space-1));
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.welcome-bubble {
  padding: var(--space-1) var(--space-3);
  border-radius: 1rem;
  background: var(--color-selected-bg);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 700;
}

/* On the name card she asks until a name is typed, then greets by it; welcome.js marks a blank one. */
.welcome-greeting,
.welcome-card:has(#name:not(:placeholder-shown):not([data-blank])) .welcome-asking {
  display: none;
}

.welcome-card:has(#name:not(:placeholder-shown):not([data-blank])) .welcome-greeting {
  display: grid;
}

.welcome-actions {
  display: grid;
  gap: var(--space-2);
}

/* Only once welcome.js marks the current card, so without JS every card stays face-on. */
.welcome-cards:has(.is-current) .welcome-card:not(.is-current) .ui\:card {
  transform: rotateY(-25deg) scale(0.92);
  opacity: 0.5;
}

.welcome-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
}

.welcome-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 999px;
  background: var(--color-border);
  transition: width 0.3s ease;
}

.welcome-dot[aria-current="step"] {
  width: 1.5rem;
  background: var(--color-primary);
}

@media (prefers-reduced-motion: reduce) {
  .welcome-cards,
  .welcome-card .ui\:card,
  .welcome-dot {
    transition: none;
  }
}

/* Share link, AI app connection, and error pages: one card in the middle of the screen. */
.centered main {
  gap: var(--space-4);
  text-align: center;
}

/* card-body's flex: auto would stretch the card to the full height of main. */
.centered main > .ui\:card {
  flex: none;
}

.centered .ui\:alert {
  justify-items: center;
  text-align: center;
}

/* Error pages: a sheet card with Yomochi standing in for the middle digit. */
.error-page {
  --card-p: var(--space-8) var(--space-6);
}

.error-page h1 {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 800;
}

.error-page .lead {
  margin: 0 0 var(--space-2);
  color: var(--color-muted);
}

.error-code {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  color: var(--color-leaf-dark);
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
}

.farewell .ui\:modal-box {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  text-align: center;
}

/* The box takes the opening focus (farewell.tsx), so the ✕ shows no ring she has to share. */
.farewell .ui\:modal-box:focus {
  outline: none;
}

/* The bubble starts below the ✕, and the centered title needs none of the room kept beside it. */
.farewell .welcome-art {
  margin-block-start: var(--space-6);
}

/* Breaks between phrases where the browser can, not mid-word as balance alone does in Japanese. */
.farewell .welcome-bubble {
  text-wrap: balance;
  word-break: auto-phrase;
}

.farewell h2 {
  padding-inline: 0;
}

/* Sign in with Apple: black with white text, inverted on the dark theme (Apple's HIG). */
.apple-button {
  margin-block-start: var(--space-2);
  border-color: #000;
  background: #000;
  color: #fff;
}

:root[data-theme="hiyori-dark"] .apple-button {
  border-color: #fff;
  background: #fff;
  color: #000;
}

.apple-logo {
  width: 1em;
  height: 1.2em;
  fill: currentColor;
}
