@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,700;9..144,800&display=swap");

:root {
  --ink: #1d2925;
  --muted: #69736f;
  --paper: #f5f0e8;
  --card: #fffdf8;
  --green: #1f6b52;
  --green-dark: #154d3c;
  --lime: #d9ee91;
  --coral: #f28469;
  --yellow: #f4c95d;
  --line: rgba(29, 41, 37, 0.11);
  --shadow: 0 20px 55px rgba(38, 53, 46, 0.12);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 3%, rgba(217, 238, 145, 0.55), transparent 26rem),
    var(--paper);
  font-family: "DM Sans", sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

#app:focus {
  outline: none;
}

.app-shell {
  width: min(100%, 1120px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 max(18px, env(safe-area-inset-right)) 36px max(18px, env(safe-area-inset-left));
}

.topbar {
  height: 84px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 12px;
}

.brand {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: "Fraunces", serif;
  font-size: 21px;
  font-weight: 800;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #fff;
  background: var(--green);
  border-radius: 13px 13px 13px 4px;
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  letter-spacing: -0.03em;
}

.icon-button,
.saved-pill {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.82);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.icon-button svg,
.saved-pill svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.back-button {
  visibility: hidden;
}

.saved-pill {
  justify-self: end;
  width: 46px;
  height: 46px;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  position: relative;
}

.saved-pill span {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  color: #fff;
  background: var(--coral);
  border: 2px solid var(--paper);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

.hero {
  padding: 48px 0 38px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 2px;
  background: currentColor;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 18px;
  font-family: "Fraunces", serif;
  font-size: clamp(44px, 8vw, 82px);
  line-height: 0.96;
  letter-spacing: -0.055em;
}

.hero-copy {
  max-width: 555px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 16px 0 20px;
}

.section-head h2 {
  margin-bottom: 3px;
  font-family: "Fraunces", serif;
  font-size: 29px;
  letter-spacing: -0.035em;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.category-card {
  min-height: 194px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.category-card::after {
  content: "";
  width: 120px;
  height: 120px;
  position: absolute;
  right: -25px;
  bottom: -35px;
  background: rgba(255, 255, 255, 0.32);
  border-radius: 50%;
}

.category-card[data-category="home"] { background: #d9ee91; }
.category-card[data-category="technology"] { background: #b9dbe3; }
.category-card[data-category="food"] { background: #f6c96b; }
.category-card[data-category="kids"] { background: #efaa98; }

.category-icon {
  font-size: 38px;
  filter: saturate(0.82);
}

.category-card h3 {
  margin: 0 0 4px;
  font-family: "Fraunces", serif;
  font-size: 26px;
}

.category-card p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.67;
}

.card-arrow {
  position: absolute;
  right: 22px;
  top: 22px;
  font-size: 23px;
}

.hack-screen {
  max-width: 650px;
  margin: 22px auto 0;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.progress-track {
  height: 5px;
  margin-bottom: 16px;
  background: rgba(31, 107, 82, 0.12);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: inherit;
  transition: width 300ms ease;
}

.hack-card {
  background: var(--card);
  border: 1px solid rgba(29, 41, 37, 0.07);
  border-radius: 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hack-image-wrap {
  height: min(47vh, 390px);
  min-height: 290px;
  position: relative;
  background: #dce5df;
  overflow: hidden;
}

.hack-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hack-image-wrap::after {
  content: "";
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(transparent, rgba(15, 28, 23, 0.58));
  pointer-events: none;
}

.image-label {
  position: absolute;
  z-index: 1;
  left: 20px;
  bottom: 18px;
  padding: 8px 12px;
  color: #fff;
  background: rgba(15, 28, 23, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 99px;
  backdrop-filter: blur(8px);
  font-size: 12px;
  font-weight: 600;
}

.hack-copy {
  padding: 24px 24px 21px;
}

.hack-copy h1 {
  margin-bottom: 12px;
  font-size: clamp(31px, 8vw, 43px);
  line-height: 1.02;
}

.hack-copy p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.hack-tip {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr;
  gap: 10px;
  margin-top: 16px;
}

.action-button {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  font-weight: 700;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.action-button:hover {
  transform: translateY(-2px);
}

.action-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.action-button.vote-down:hover { background: #f9ddd5; }
.action-button.vote-up:hover { background: #e4f1bc; }
.action-button.favorite {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}
.action-button.favorite.is-saved {
  color: var(--green-dark);
  background: var(--lime);
  border-color: var(--lime);
}

.score-badge {
  min-width: 22px;
  padding: 2px 5px;
  color: var(--muted);
  background: rgba(29, 41, 37, 0.07);
  border-radius: 99px;
  font-size: 11px;
}

.saved-screen {
  padding-top: 32px;
}

.saved-screen h1 {
  margin-bottom: 12px;
  font-size: clamp(42px, 8vw, 70px);
}

.saved-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 30px;
}

.saved-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 23px;
  overflow: hidden;
}

.saved-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.saved-card-copy {
  padding: 17px;
}

.saved-card-copy span {
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.saved-card h3 {
  margin: 7px 0 14px;
  font-family: "Fraunces", serif;
  font-size: 21px;
  line-height: 1.1;
}

.remove-button {
  padding: 0;
  color: var(--muted);
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.empty-state {
  margin-top: 34px;
  padding: 54px 24px;
  text-align: center;
  background: rgba(255, 253, 248, 0.68);
  border: 1px dashed rgba(29, 41, 37, 0.22);
  border-radius: var(--radius);
}

.empty-state .empty-icon {
  display: block;
  margin-bottom: 14px;
  font-size: 42px;
}

.empty-state h2 {
  margin-bottom: 8px;
  font-family: "Fraunces", serif;
}

.empty-state p {
  max-width: 380px;
  margin: 0 auto 22px;
  color: var(--muted);
}

.primary-button {
  padding: 14px 20px;
  color: #fff;
  background: var(--green);
  border: 0;
  border-radius: 15px;
  font-weight: 700;
  cursor: pointer;
}

.toast {
  max-width: calc(100% - 32px);
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  padding: 12px 17px;
  color: #fff;
  background: var(--ink);
  border-radius: 99px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.fade-in {
  animation: fadeIn 260ms ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
}

@media (min-width: 760px) {
  .app-shell { padding-inline: 32px; }
  .topbar { grid-template-columns: 50px 1fr 50px; }
  .category-grid { grid-template-columns: repeat(4, 1fr); }
  .category-card { min-height: 270px; }
  .saved-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 460px) {
  .app-shell { padding-inline: 14px; }
  .topbar { height: 72px; }
  .brand { font-size: 19px; }
  .brand-mark { width: 36px; height: 36px; }
  .hero { padding-top: 35px; }
  .hero-copy { font-size: 15px; }
  .category-card { min-height: 165px; padding: 18px; border-radius: 23px; }
  .category-card h3 { font-size: 22px; }
  .category-icon { font-size: 31px; }
  .hack-screen { margin-top: 8px; }
  .hack-card { border-radius: 25px; }
  .hack-image-wrap { min-height: 250px; height: 39vh; }
  .hack-copy { padding: 20px 20px 18px; }
  .action-row { grid-template-columns: 1fr 1fr; }
  .action-button.favorite { grid-column: 1 / -1; }
  .action-button { min-height: 56px; }
  .saved-grid { grid-template-columns: 1fr; }
}

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