@font-face {
  font-family: "Miras Sans";
  src: url("assets/Roboto-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Miras Sans";
  src: url("assets/Roboto-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Miras Serif";
  src: url("assets/RobotoSlab-VariableFont_wght.ttf") format("truetype");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fbf7ef;
  --raised: #fffdf8;
  --sunken: #f1e8d9;
  --ink: #231f1a;
  --muted: #655d51;
  --forest: #315326;
  --petrol: #174743;
  --teal: #2d817a;
  --gold: #f2b705;
  --terracotta: #b34f2f;
  --border: #dfd2bd;
  --border-strong: #8a7c68;
  --success: #356a31;
  --warning: #704b00;
  --error: #a12b2b;
  --shadow: 0 14px 40px rgb(52 44 32 / 8%);
  --radius: 18px;
  --radius-large: 24px;
  --content: 1480px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 20% 0%, rgb(49 83 38 / 4%), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family: "Miras Sans", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--petrol);
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: 10px;
  background: var(--petrol);
  color: white;
}

.skip-link:focus {
  transform: none;
}

[hidden] {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  align-items: center;
  gap: clamp(32px, 6vw, 96px);
  padding: clamp(28px, 6vw, 90px);
  background:
    linear-gradient(120deg, rgb(49 83 38 / 8%), transparent 46%),
    var(--paper);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 30px;
  max-width: 760px;
}

.auth-brand img {
  width: clamp(116px, 15vw, 220px);
  filter: drop-shadow(0 14px 30px rgb(23 71 67 / 12%));
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: "Miras Serif", Georgia, serif;
  color: var(--petrol);
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  line-height: 1.04;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.auth-brand p:not(.eyebrow) {
  max-width: 610px;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  line-height: 1.65;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--terracotta);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-card {
  display: grid;
  gap: 20px;
  padding: clamp(26px, 4vw, 44px);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  background: rgb(255 253 248 / 94%);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  outline: none;
  background: white;
  color: var(--ink);
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(45 129 122 / 32%);
  outline-offset: 3px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 11px 20px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--petrol);
  background: var(--petrol);
  color: white;
}

.primary-button:hover {
  background: #0d3835;
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--petrol);
}

.secondary-button:hover {
  border-color: var(--teal);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.privacy-note,
.form-error {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.form-error:not(:empty) {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fce9e7;
  color: var(--error);
}

.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(520px, 1fr) auto;
  align-items: center;
  gap: 28px;
  min-height: 76px;
  padding: 10px max(24px, calc((100vw - var(--content)) / 2));
  border-bottom: 1px solid var(--border);
  background: rgb(251 247 239 / 94%);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--petrol);
  font-family: "Miras Serif", Georgia, serif;
  font-size: 1.45rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 28px);
}

.main-nav a {
  position: relative;
  padding: 16px 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.main-nav a::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 8px;
  left: 0;
  height: 2px;
  transform: scaleX(0);
  background: var(--teal);
  transition: transform 180ms ease;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--petrol);
}

.main-nav a.active::after {
  transform: scaleX(1);
}

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

.sync-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid #b7d6c7;
  border-radius: 999px;
  background: #edf7f0;
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.avatar-button,
.mobile-menu {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.avatar-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font-family: "Miras Serif", Georgia, serif;
  font-weight: 800;
}

.mobile-menu {
  display: none;
  font-size: 1.5rem;
}

main {
  max-width: var(--content);
  min-height: calc(100vh - 130px);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 42px) 24px 72px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: reveal 220ms ease-out;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  margin-bottom: 24px;
}

.search-field {
  position: relative;
  display: block;
}

.search-field span {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 18px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.6rem;
  font-weight: 400;
}

.search-field input {
  padding-left: 52px;
  border-color: var(--border);
  background: var(--raised);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 0.82fr);
  align-items: start;
  gap: 20px;
}

.featured-card,
.panel,
.content-section,
.table-card,
.empty-state {
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  background: rgb(255 253 248 / 90%);
  box-shadow: 0 2px 0 rgb(49 83 38 / 2%);
}

.featured-card {
  padding: clamp(18px, 2vw, 30px);
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading.inline,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h1,
.section-heading h2,
.panel-heading h2 {
  margin-bottom: 0;
}

.section-heading.inline a,
.panel-heading a {
  font-weight: 700;
  text-decoration: none;
}

.featured-recipe {
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(280px, 0.9fr);
  min-height: 430px;
  border-radius: var(--radius);
  background: var(--sunken);
}

.featured-image {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: cover;
}

.featured-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(24px, 4vw, 54px);
  background:
    linear-gradient(135deg, rgb(255 253 248 / 70%), transparent),
    var(--sunken);
}

.heritage-note {
  display: inline-block;
  margin-bottom: 22px;
  padding: 8px 13px;
  transform: rotate(-1deg);
  border-bottom: 2px solid var(--gold);
  color: var(--forest);
  font-family: "Miras Serif", Georgia, serif;
  font-style: italic;
}

.featured-copy h2 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.02;
}

.featured-copy p {
  color: var(--muted);
  line-height: 1.6;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 24px;
}

.meta-chip,
.status-pill,
.source-kind {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgb(255 253 248 / 75%);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.utility-column {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading span,
.panel-heading a {
  color: var(--muted);
  font-size: 0.82rem;
}

.weekly-plan,
.consume-list {
  display: grid;
  gap: 8px;
}

.plan-row,
.consume-row {
  display: grid;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f7f4ec;
}

.plan-row {
  grid-template-columns: 44px 1fr;
}

.plan-day {
  display: grid;
  place-items: center;
  min-height: 30px;
  border-radius: 8px;
  background: #e6eee2;
  color: var(--forest);
  font-size: 0.78rem;
  font-weight: 700;
}

.consume-row {
  grid-template-columns: 1fr auto;
}

.consume-row small,
.plan-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.compact-summary dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 11px 20px;
  margin: 0;
}

.compact-summary dt {
  color: var(--muted);
}

.compact-summary dd {
  margin: 0;
  color: var(--petrol);
  font-weight: 700;
}

.content-section {
  margin-top: 22px;
  padding: clamp(18px, 2vw, 28px);
}

.recipe-grid,
.source-grid,
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.recipe-card,
.source-card,
.product-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--raised);
}

.recipe-card {
  position: relative;
  min-height: 310px;
  cursor: pointer;
}

.recipe-card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.recipe-card-copy,
.source-card-copy,
.product-card {
  padding: 16px;
}

.recipe-card h3,
.source-card h3,
.product-card h3 {
  margin: 0 0 8px;
  color: var(--petrol);
  font-family: "Miras Serif", Georgia, serif;
  font-size: 1.18rem;
}

.recipe-card p,
.source-card p,
.product-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.bookmark {
  position: absolute;
  top: 0;
  right: 18px;
  width: 20px;
  height: 38px;
  background: var(--gold);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%);
}

.source-strip {
  background:
    linear-gradient(120deg, rgb(241 232 217 / 40%), transparent),
    var(--raised);
}

.source-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.source-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  min-height: 126px;
}

.source-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--sunken);
}

.source-kind {
  margin-top: 10px;
  background: var(--sunken);
  color: var(--forest);
}

.page-heading {
  margin-bottom: 26px;
  padding: 14px 0;
}

.page-heading h1 {
  margin-bottom: 8px;
}

.page-heading > p:last-child {
  color: var(--muted);
}

.all-recipes {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.empty-state {
  display: grid;
  min-height: 460px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 40px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 80px;
  height: 80px;
  place-items: center;
  border-radius: 50%;
  background: var(--sunken);
  color: var(--petrol);
  font-size: 2.6rem;
}

.empty-state p {
  max-width: 520px;
  color: var(--muted);
}

.table-card {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  background: var(--sunken);
  color: var(--petrol);
  font-family: "Miras Serif", Georgia, serif;
}

tr:last-child td {
  border-bottom: 0;
}

.status-pill.present { background: #e6f2e8; color: var(--success); }
.status-pill.low { background: #fff1c9; color: var(--warning); }
.status-pill.absent { background: #fce3df; color: var(--error); }

.product-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.product-card {
  min-height: 190px;
}

.product-brand {
  display: block;
  margin-bottom: 12px;
  color: var(--terracotta);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-grid.full {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.empty-inline {
  grid-column: 1 / -1;
  padding: 36px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px max(24px, calc((100vw - var(--content)) / 2));
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 18px;
  transform: translateY(160%);
  border-radius: 14px;
  background: var(--petrol);
  color: white;
  box-shadow: var(--shadow);
  transition: transform 200ms ease;
}

.toast.show {
  transform: translateY(0);
}

@media (max-width: 1220px) {
  .topbar {
    grid-template-columns: auto auto 1fr;
  }

  .mobile-menu {
    display: block;
  }

  .main-nav {
    position: absolute;
    top: 76px;
    right: 16px;
    left: 16px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--raised);
    box-shadow: var(--shadow);
  }

  .main-nav.open {
    display: flex;
  }

  .main-nav a {
    padding: 12px 14px;
  }

  .main-nav a::after {
    display: none;
  }

  .user-actions {
    justify-self: end;
  }

  .all-recipes,
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    justify-content: center;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .utility-column {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .featured-recipe {
    min-height: 380px;
  }

  .source-grid,
  .source-grid.full {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto auto;
    padding: 10px 16px;
  }

  .brand span,
  .sync-chip,
  .avatar-button > span:last-child {
    display: none;
  }

  .brand img {
    width: 44px;
    height: 44px;
  }

  .mobile-menu {
    grid-column: 2;
    grid-row: 1;
  }

  .user-actions {
    position: static;
    grid-column: 3;
    grid-row: 1;
  }

  main {
    padding: 18px 14px 88px;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .featured-recipe {
    grid-template-columns: 1fr;
  }

  .featured-image {
    min-height: 240px;
    max-height: 320px;
  }

  .featured-copy {
    padding: 24px;
  }

  .utility-column,
  .recipe-grid,
  .all-recipes,
  .product-grid,
  .source-grid,
  .source-grid.full {
    grid-template-columns: 1fr;
  }

  .recipe-card img {
    height: 210px;
  }

  .source-card {
    grid-template-columns: 90px 1fr;
  }

  .section-heading.inline {
    align-items: flex-end;
  }

  footer {
    flex-direction: column;
    padding: 20px 16px 90px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
