/* ============================================================
   Font View — UI estilo Apple (HIG)
   A propria interface usa SF Pro Display (fontes do usuario).
   ============================================================ */

@font-face {
  font-family: "UI";
  src: url("../fonts/Apple/SFPRODISPLAYREGULAR.OTF") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "UI";
  src: url("../fonts/Apple/SFPRODISPLAYMEDIUM.OTF") format("opentype");
  font-weight: 500 600;
  font-display: swap;
}
@font-face {
  font-family: "UI";
  src: url("../fonts/Apple/SFPRODISPLAYBOLD.OTF") format("opentype");
  font-weight: 700 900;
  font-display: swap;
}

:root {
  --font-ui: "UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Light */
  --bg: #f5f5f7;
  --bg-grad-a: #fbfbfd;
  --bg-grad-b: #eef0f3;
  --surface: rgba(255, 255, 255, .72);
  --surface-solid: #ffffff;
  --field: #ffffff;
  --track: rgba(120, 120, 128, .12);
  --text: #1d1d1f;
  --muted: #86868b;
  --hairline: rgba(0, 0, 0, .08);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, .12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 12px rgba(0, 0, 0, .05);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, .06), 0 12px 34px rgba(0, 0, 0, .09);
  --seg-thumb: #ffffff;
  --seg-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 1px rgba(0, 0, 0, .04);
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-grad-a: #1c1c1e;
  --bg-grad-b: #000000;
  --surface: rgba(30, 30, 32, .62);
  --surface-solid: #1c1c1e;
  --field: #2c2c2e;
  --track: rgba(120, 120, 128, .24);
  --text: #f5f5f7;
  --muted: #98989d;
  --hairline: rgba(255, 255, 255, .1);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, .22);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 40px rgba(0, 0, 0, .55);
  --seg-thumb: #636366;
  --seg-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-ui);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Gradiente fixo em camada propria: rolagem suave mesmo com centenas de cards */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% -10%, var(--bg-grad-a) 0%, var(--bg) 55%);
}

/* ---------- Topbar (vidro fosco) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px clamp(16px, 4vw, 32px) 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.brand-titles { display: flex; align-items: baseline; gap: 12px; }
.brand-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Seção recolhível (controles + chips) ---------- */
.collapsible {
  display: grid;
  grid-template-rows: 1fr;
  margin-top: 14px;
  transition: grid-template-rows .34s cubic-bezier(.4, 0, .2, 1),
              margin-top .34s cubic-bezier(.4, 0, .2, 1);
}
/* evita animar o recolhimento no carregamento inicial */
.topbar.no-anim .collapsible,
.topbar.no-anim .nav-toggle svg { transition: none; }
.collapsible-inner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Botão de expandir/recolher: some no desktop, aparece no mobile */
.nav-toggle {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, background .2s ease;
}
.nav-toggle:hover { background: var(--surface-2, var(--track)); }
.nav-toggle:active { transform: scale(.95); }
.nav-toggle svg { transition: transform .34s cubic-bezier(.4, 0, .2, 1); }
.topbar.collapsed .nav-toggle svg { transform: rotate(180deg); }
.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.021em;
}
.count {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Hero input ---------- */
.sample-input {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 19px;
  font-weight: 400;
  padding: 15px 20px;
  border-radius: 16px;
  border: 1px solid var(--hairline);
  background: var(--field);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.sample-input::placeholder { color: var(--muted); }
.sample-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---------- Control row ---------- */
.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.search-wrap {
  position: relative;
  flex: 1 1 200px;
  min-width: 170px;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 13px;
  color: var(--muted);
  pointer-events: none;
}
.search {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 15px;
  padding: 10px 14px 10px 36px;
  border-radius: 980px;
  border: 1px solid var(--hairline);
  background: var(--field);
  color: var(--text);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.search::placeholder { color: var(--muted); }
.search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.search::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------- Segmented control (iOS) ---------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--track);
  border-radius: 12px;
}
.segmented button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .22s ease, box-shadow .22s ease, transform .1s ease;
}
.segmented button:hover:not(.active) { color: var(--text); opacity: .7; }
.segmented button:active { transform: scale(.97); }
.segmented button.active {
  background: var(--seg-thumb);
  box-shadow: var(--seg-shadow);
}

/* ---------- Size control ---------- */
.size-ctl {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 980px;
  background: var(--track);
  color: var(--muted);
  font-size: 13px;
}
.size-label { font-weight: 600; font-size: 15px; color: var(--text); }
.size-ctl output {
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 130px;
  height: 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25), 0 0 0 .5px rgba(0, 0, 0, .04);
  cursor: pointer;
  transition: transform .1s ease;
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); cursor: pointer;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, background .2s ease;
}
.theme-toggle:hover { transform: scale(1.05); }
.theme-toggle:active { transform: scale(.95); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--font-ui);
  border: 1px solid var(--hairline);
  background: var(--field);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 980px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .16s ease;
}
.chip:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--hairline)); }
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 12px var(--accent-soft);
}

/* ---------- List / Cards ---------- */
.list {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 32px) 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  position: relative;
  background: var(--surface-solid);
  border: 1px solid var(--hairline);
  border-radius: 22px;
  padding: 22px 26px 24px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.card-name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.card-meta { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-cat {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--track);
  border-radius: 980px;
  padding: 3px 11px;
  white-space: nowrap;
}

.card-sample {
  margin: 0;
  line-height: 1.22;
  word-break: break-word;
  color: var(--text);
}

.empty {
  max-width: 1180px;
  margin: 0 auto;
  text-align: center;
  color: var(--muted);
  padding: 80px 20px;
  font-size: 15px;
}
.empty code {
  background: var(--track);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 13px;
}

@media (max-width: 680px) {
  .segmented { order: 3; width: 100%; justify-content: space-between; }
  .segmented button { flex: 1; text-align: center; padding: 7px 6px; }
  .size-ctl { order: 2; }
  input[type="range"] { width: 90px; }
  .card { padding: 18px 18px 20px; border-radius: 18px; }

  /* No mobile: mostra o botão e permite recolher a seção de controles */
  .nav-toggle { display: inline-grid; }
  .topbar.collapsed .collapsible { grid-template-rows: 0fr; margin-top: 0; }
}
