/* resource/style.css — background.jpeg is in this same folder */

:root {
  --bg: #0f0f0f;
  --sur: #1a1a1a;
  --sur2: #242424;
  --bdr: #2e2e2e;
  --txt: #f0f0f0;
  --muted: #888;
  --org: #ff6b35;
  --orh: #e85a25;
  --grn: #4ade80;
  --sans: "Inter", system-ui, sans-serif;
  --display: "Syne", sans-serif;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--txt);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img {
  display: block;
  max-width: 100%;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font-family: var(--sans);
  cursor: pointer;
  border: none;
  background: none;
}
input {
  font-family: var(--sans);
}
ul,
ol {
  list-style: none;
}
.hidden {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

/* Loader */
.ls {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #0f0f0f;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s;
}
.ls.out {
  opacity: 0;
  pointer-events: none;
}
.ls-inner {
  text-align: center;
}
.ls-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
}
.ls-name {
  font-family: var(--display);
  font-size: 2.5rem;
  color: var(--org);
  letter-spacing: 0.1em;
  overflow: hidden;
  width: 0;
  white-space: nowrap;
  animation: typeIn 1.3s steps(7) 0.2s forwards;
}
.ls-bar {
  width: 120px;
  height: 2px;
  background: #2e2e2e;
  margin: 0.75rem auto 0;
}
.ls-fill {
  height: 100%;
  width: 0;
  background: var(--org);
  animation: barFill 1.3s ease 0.2s forwards;
}
@keyframes typeIn {
  to {
    width: 12ch;
  }
}
@keyframes barFill {
  to {
    width: 100%;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* App */
#app[hidden] {
  display: none;
}
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 2rem;
  border-bottom: 1px solid var(--bdr);
  position: sticky;
  top: 0;
  background: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(8px);
  z-index: 100;
}
.brand {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--org);
  letter-spacing: 0.05em;
}
.brand span {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-left: 0.5rem;
  font-family: var(--sans);
  font-weight: 400;
}
nav {
  display: flex;
  gap: 0.5rem;
}
.btn-ghost {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  transition:
    color 0.2s,
    background 0.2s;
}
.btn-ghost:hover {
  color: var(--txt);
  background: var(--sur2);
}
.btn-ghost.outline {
  border: 1px solid var(--bdr);
}
.badge {
  background: var(--org);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 3px;
}

/* Hero — compact, no big blank area */
.hero {
  background: url("background.jpeg") center / cover no-repeat;
  position: relative;
  padding: 3.5rem 1.5rem 4rem;
  text-align: center;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}
.hero > * {
  position: relative;
  z-index: 1;
}
.tag-line {
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--org);
  margin-bottom: 0.6rem;
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
  margin-bottom: 2rem;
}
.hero h1 em {
  color: var(--org);
  font-style: normal;
}

/* Search card */
.search-card {
  background: rgba(26, 26, 26, 0.95);
  border: 1px solid var(--bdr);
  border-radius: 14px;
  padding: 1.1rem 1.3rem 0.9rem;
  max-width: 620px;
  margin: 0 auto;
  text-align: left;
}
.tag-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  border: 1px solid var(--bdr);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  transition: border-color 0.2s;
}
.tag-wrap:focus-within {
  border-color: var(--org);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 107, 53, 0.15);
  color: var(--org);
  border: 1px solid rgba(255, 107, 53, 0.3);
  font-size: 0.8rem;
  padding: 0.18rem 0.5rem 0.18rem 0.65rem;
  border-radius: 4px;
}
.tag-remove {
  opacity: 0.5;
  font-size: 0.85rem;
}
.tag-remove:hover {
  opacity: 1;
}
.ac-wrap {
  position: relative;
  flex: 1;
  min-width: 120px;
}
.tag-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--txt);
}
.tag-input::placeholder {
  color: #555;
}
.ac-list {
  position: absolute;
  top: calc(100% + 4px);
  left: -8px;
  right: 0;
  background: var(--sur);
  border: 1px solid var(--bdr);
  border-radius: 8px;
  z-index: 300;
  max-height: 180px;
  overflow-y: auto;
}
.ac-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--txt);
}
.ac-list li:hover {
  background: var(--sur2);
}
.ac-img {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
}
.search-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.filters {
  display: flex;
  gap: 0.35rem;
}
.filters label {
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--bdr);
  user-select: none;
  transition: all 0.2s;
}
.filters label:has(input:checked) {
  border-color: var(--org);
  color: var(--org);
  background: rgba(255, 107, 53, 0.1);
}
.btn-primary {
  background: var(--org);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  transition: background 0.2s;
}
.btn-primary:hover:not(:disabled) {
  background: var(--orh);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary.loading::after {
  content: "…";
}
.hint {
  margin-top: 0.5rem;
  font-size: 0.68rem;
  color: #444;
}
.hint kbd {
  font-family: var(--sans);
  font-size: 0.65rem;
  background: var(--sur2);
  border: 1px solid var(--bdr);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  color: var(--muted);
}

/* Main — KEY FIX: no flex:1, no padding when empty */
#main {
  padding: 0;
}
#main.has-content {
  padding: 2rem 2rem 3rem;
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
}

/* States */
.state-box {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--muted);
}
.state-box .ico {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}
.state-box h3 {
  color: var(--txt);
  font-family: var(--display);
  margin-bottom: 0.35rem;
}
.spinner-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 2rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.spinner {
  width: 30px;
  height: 30px;
  border: 2px solid var(--bdr);
  border-top-color: var(--org);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Results */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}
.results-bar h2 {
  font-family: var(--display);
  font-size: 1.2rem;
}
.results-bar span {
  font-size: 0.8rem;
  color: var(--muted);
}
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

/* Card */
.recipe-card {
  background: var(--sur);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--bdr);
  cursor: pointer;
  transition: border-color 0.2s;
}
.recipe-card:hover {
  border-color: #444;
}
.card-thumb {
  position: relative;
  height: 165px;
  overflow: hidden;
  background: var(--sur2);
}
.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-save {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  z-index: 2;
}
.card-save:hover {
  background: rgba(0, 0, 0, 0.85);
}
.card-save.saved {
  background: rgba(255, 107, 53, 0.2);
}
.card-body {
  padding: 0.75rem 0.9rem 0.9rem;
}
.card-title {
  font-family: var(--display);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.4rem;
  color: var(--txt);
}
.card-meta {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.m-tag {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.14rem 0.45rem;
  border-radius: 4px;
}
.m-tag.used {
  background: rgba(74, 222, 128, 0.12);
  color: var(--grn);
}
.m-tag.miss {
  background: rgba(255, 107, 53, 0.12);
  color: var(--org);
}
.m-tag.lk {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
}

/* Detail */
.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.back-btn {
  color: var(--muted);
  font-size: 0.82rem;
  border: 1px solid var(--bdr);
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  transition: all 0.2s;
}
.back-btn:hover {
  color: var(--txt);
  border-color: #555;
}
.save-btn {
  color: var(--org);
  font-size: 0.82rem;
  border: 1px solid rgba(255, 107, 53, 0.35);
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  transition: all 0.2s;
}
.save-btn:hover {
  background: rgba(255, 107, 53, 0.1);
}
.save-btn.saved {
  background: var(--org);
  color: #fff;
  border-color: var(--org);
}
.detail-hero {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 2rem;
  margin-bottom: 2rem;
  align-items: start;
}
.detail-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 10px;
}
.detail-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  line-height: 1.15;
  margin-bottom: 0.9rem;
}
.stats {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.stat {
  display: flex;
  flex-direction: column;
}
.stat-v {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--org);
}
.stat-l {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.dtags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}
.dtag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  background: var(--sur2);
  color: var(--muted);
  text-transform: capitalize;
}
.dtag.c {
  color: #c084fc;
  background: rgba(192, 132, 252, 0.1);
}
.dtag.t {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
}
.nut {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  background: var(--sur2);
  border: 1px solid var(--bdr);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.9rem;
}
.nut-item {
  text-align: center;
}
.nut-v {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--txt);
}
.nut-l {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.detail-body {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.detail-body.two-col {
  grid-template-columns: 1fr 2fr;
}
.sec-head {
  font-family: var(--display);
  font-size: 1rem;
  border-bottom: 1px solid var(--bdr);
  padding-bottom: 0.4rem;
  margin-bottom: 0.8rem;
  color: var(--txt);
}
.ing-list {
  display: flex;
  flex-direction: column;
}
.ing-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.32rem 0;
  border-bottom: 1px solid var(--bdr);
  color: #ccc;
}
.ing-item::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--org);
  flex-shrink: 0;
}
.steps {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.step {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 0.6rem;
  align-items: start;
}
.step-n {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--org);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
}
.step-t,
.plain-ins {
  font-size: 0.88rem;
  line-height: 1.7;
  color: #ccc;
}
.no-ins {
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
}
.src-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--org);
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255, 107, 53, 0.35);
}

/* Similar */
.sim-section {
  margin-top: 1.5rem;
  border-top: 1px solid var(--bdr);
  padding-top: 1.2rem;
}
.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}
.sim-card {
  background: var(--sur);
  border: 1px solid var(--bdr);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
}
.sim-card:hover {
  border-color: #444;
}
.sim-img {
  width: 100%;
  height: 95px;
  object-fit: cover;
}
.sim-body {
  padding: 0.45rem 0.6rem;
}
.sim-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--txt);
}
.sim-time {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* Saved */
.saved-panel {
  background: var(--sur);
  border: 1px solid var(--bdr);
  border-radius: 10px;
  padding: 1.2rem;
}
.saved-panel h2 {
  font-family: var(--display);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}
.saved-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.5rem 0;
}
.saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--bdr);
  border-radius: 6px;
  gap: 0.6rem;
}
.saved-item:hover {
  background: var(--sur2);
}
.saved-name {
  font-size: 0.85rem;
  cursor: pointer;
  flex: 1;
  color: var(--txt);
}
.saved-name:hover {
  color: var(--org);
}
.saved-del {
  font-size: 0.8rem;
  color: var(--muted);
}
.saved-del:hover {
  color: #f87171;
}

/* Footer — always hugs bottom of content, no gap */
footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--bdr);
  text-align: center;
  margin-top: auto;
}
footer p {
  color: var(--muted);
  font-size: 0.75rem;
}
footer strong {
  color: #aaa;
}
footer a {
  color: var(--org);
}

/* Responsive */
@media (max-width: 768px) {
  header {
    padding: 0.75rem 1.25rem;
  }
  .hero {
    padding: 2.5rem 1rem 3rem;
  }
  .detail-hero,
  .detail-body.two-col {
    grid-template-columns: 1fr;
  }
  .nut {
    grid-template-columns: repeat(2, 1fr);
  }
  #main.has-content {
    padding: 1.5rem 1rem 2.5rem;
  }
}
@media (max-width: 520px) {
  .recipe-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
  }
  .search-foot {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-primary {
    text-align: center;
  }
}
@media (max-width: 360px) {
  .recipe-grid {
    grid-template-columns: 1fr;
  }
}
