/* ---------------------------------------------------
   Recipe Scaler — design system
   Ported from the "Mobile" Figma frames. Values here map 1:1 to the
   file's variables: Instrument Serif for display, Inter for UI, black
   CTAs, #EDEDED fills, #635F5C grey, 24/36 spacing.
--------------------------------------------------- */

:root {
  /* Colours (Figma variables) */
  --black: #000000;
  --white: #ffffff;
  --ed: #ededed;          /* fills: cards, image placeholders, steppers */
  --grey: #635f5c;        /* muted labels */
  --searchbar: #e8e4df;

  /* Supporting neutrals used by the form components */
  --ink: #2d2926;         /* body/label text */
  --muted: #6b7280;       /* secondary copy */
  --placeholder: #9ca3af; /* input placeholders, dividers */
  --line: #e5e7eb;        /* borders */
  --input-bg: #f9fafb;

  /* Spacing */
  --space-between: 24px;
  --space-between-sections: 36px;
  --bottom-margin: 36px;

  /* Radii */
  --image-corner-radius: 8px;
  --radius-input: 14px;
  --radius-button: 12px;
  --radius-card: 12px;

  /* The phone column width from the design (402px frame - 24px gutters) */
  --screen-max: 402px;
}

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

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--black);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

/* Every page is a phone-width column, centred on larger screens */
.screen {
  width: 100%;
  max-width: var(--screen-max);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: var(--space-between-sections);
}

/* Pages with the floating navbar need room so it never covers content */
.screen.has-nav {
  padding-bottom: calc(var(--bottom-margin) + 89px + 16px);
}

/* Full-bleed pages (recipe) manage their own horizontal padding */
.screen.bleed {
  padding: 0 0 40px;
  gap: 0;
}

/* ---------------------------------------------------
   Type
--------------------------------------------------- */
.h1 {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 36px;
  font-weight: 400;
  line-height: 1.1;
  color: var(--black);
}

.h2 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}

.h3 { font-size: 14px; font-weight: 500; }
.h4 { font-size: 12px; font-weight: 500; }

.muted { color: var(--muted); }

/* ---------------------------------------------------
   Forms
--------------------------------------------------- */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-between);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"] {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
}

input::placeholder { color: var(--placeholder); }

input:focus {
  outline: none;
  border-color: var(--black);
}

/* ---------------------------------------------------
   Buttons
--------------------------------------------------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 24px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  background: var(--black);
  border: none;
  border-radius: var(--radius-button);
  cursor: pointer;
}

.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* Outlined button (Continue with Google) */
.btn-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  cursor: pointer;
}

.btn-outline:active { background: var(--input-bg); }

/* A quiet text link/button */
.link {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

/* ---------------------------------------------------
   Divider ("or")
--------------------------------------------------- */
.divider {
  display: flex;
  align-items: center;
  gap: 16px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.divider span {
  font-size: 14px;
  font-weight: 500;
  color: var(--placeholder);
}

/* ---------------------------------------------------
   Auth pages
--------------------------------------------------- */
.auth-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-between);
}

.auth-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
}

.auth-footer span { color: var(--muted); }

.auth-message {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

.auth-message.error { color: #dc2626; }

.forgot-row { text-align: center; }

.forgot-row .link {
  color: var(--muted);
  text-decoration: none;
}

/* ---------------------------------------------------
   Home
--------------------------------------------------- */
/* "Add Recipe / Import via URL or PDF" card */
.add-recipe {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px 24px;
  background: var(--ed);
  border: none;
  border-radius: var(--radius-card);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.add-recipe:active { opacity: 0.85; }

.add-recipe-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: #c3c3c3;
  border-radius: var(--radius-card);
  color: var(--black);
}

.add-recipe-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--black);
}

.add-recipe-text strong { font-size: 14px; font-weight: 500; }
.add-recipe-text span { font-size: 12px; font-weight: 500; }

/* Recipe grid */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 12px;
  row-gap: var(--space-between);
}

.recipe-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: var(--black);
}

.recipe-card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--ed);
  border-radius: var(--image-corner-radius);
  object-fit: cover;
  display: block;
}

.recipe-card-title {
  font-size: 14px;
  font-weight: 500;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin: auto 0;
  text-align: center;
}

.empty-state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border-radius: 100px;
  background: var(--ed);
  color: var(--black);
}

.empty-state h2 { font-size: 20px; font-weight: 600; }

.empty-state p {
  font-size: 16px;
  color: var(--grey);
}

/* ---------------------------------------------------
   Floating bottom navbar
--------------------------------------------------- */
.navbar {
  position: fixed;
  bottom: var(--bottom-margin);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: calc(100% - 20px);
  max-width: 382px;
  padding: 12px 24px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  max-width: 98px;
  height: 65px;
  border-radius: 100px;
  text-decoration: none;
  color: var(--grey);
  font-size: 11px;
  font-weight: 600;
}

.nav-tab.active {
  background: rgba(237, 237, 237, 0.75);
  color: var(--black);
}

/* ---------------------------------------------------
   Bottom sheet (Add New Recipe) + modals
--------------------------------------------------- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: var(--screen-max);
  max-height: 92vh;
  overflow-y: auto;
  padding: 36px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--white);
  border-radius: 20px 20px 0 0;
  animation: sheet-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
}

/* Dashed "Tap to browse files" drop zone */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 120px;
  background: var(--input-bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius-input);
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
}

.upload-zone:active { background: var(--ed); }

.upload-zone span {
  font-size: 15px;
  color: var(--placeholder);
}

.upload-zone.has-file span { color: var(--ink); font-weight: 500; }

/* The real file input is hidden; the zone above triggers it */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------
   Recipe page
--------------------------------------------------- */
.recipe-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--black);
  text-decoration: none;
}

.recipe-photo {
  width: 100%;
  aspect-ratio: 402 / 301.5;
  background: var(--ed);
  object-fit: cover;
  display: block;
}

.recipe-body {
  padding: 24px 24px 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-between-sections);
}

.recipe-head {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.recipe-meta {
  display: flex;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
}

/* Servings stepper */
.servings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 25px;
}

.servings-row > span {
  font-size: 14px;
  font-weight: 500;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper button {
  padding: 4px 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--black);
  background: var(--ed);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.stepper button:active { opacity: 0.7; }

.stepper-value {
  font-size: 14px;
  font-weight: 600;
  min-width: 12px;
  text-align: center;
}

.recipe-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.recipe-section h2 { font-size: 20px; font-weight: 600; }

/* Ingredients: checkbox rows */
.ingredients-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ingredients-list li.ingredient label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.ingredients-list li.ingredient input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border: 1.5px solid #c3c3c3;
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  position: relative;
}

.ingredients-list li.ingredient input[type="checkbox"]:checked {
  background: var(--black);
  border-color: var(--black);
}

.ingredients-list li.ingredient input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.ingredients-list li.ingredient.checked .ingredient-text {
  text-decoration: line-through;
  color: var(--placeholder);
}

/* Instructions: numbered rows */
.instructions-list {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.instructions-list li.step {
  counter-increment: step;
  position: relative;
  padding-left: 28px;
}

.instructions-list li.step::before {
  content: counter(step) ".";
  position: absolute;
  left: 0;
  font-weight: 600;
}

li.section-heading {
  font-weight: 600;
  margin-top: 8px;
  counter-set: step 0;
}

/* Scaled measurements */
.scaled { font-weight: 600; }

/* A scaled amount rounded to something measurable — dotted underline,
   hover/tap reveals the true value. */
.rounded {
  position: relative;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  cursor: help;
}

.measure-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--black);
  color: var(--white);
  font-weight: 400;
  font-size: 12px;
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 6px;
  z-index: 30;
  pointer-events: none;
}

.measure-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--black);
}

.rounded:hover .measure-tip,
.rounded:focus .measure-tip,
.rounded.show .measure-tip { display: block; }

/* Notes (e.g. AllRecipes "Cook's Note") */
.note {
  background: var(--input-bg);
  border-left: 3px solid var(--ed);
  padding: 12px 14px;
  border-radius: 6px;
  color: var(--grey);
  font-size: 14px;
}

/* Guest banner */
.guest-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--ed);
  border-radius: var(--radius-card);
  font-size: 14px;
  color: var(--ink);
}

.guest-banner .link { flex-shrink: 0; }

/* ---------------------------------------------------
   Utilities
--------------------------------------------------- */
.hidden { display: none !important; }

.stack-24 { display: flex; flex-direction: column; gap: 24px; }
.stack-16 { display: flex; flex-direction: column; gap: 16px; }
