/* ================================================================
   SÖK — skafferiet. Ljus botten: --brass-dark för text, aldrig --gold.
   ================================================================ */

/* knappen i sidhuvudet: lupp + ord, syns även på mobil */
#nav-search {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
}
#nav-search svg { width: 15px; height: 15px; flex: none; }
#nav-search kbd {
  font: inherit;
  font-size: 0.68rem;
  letter-spacing: 0;
  padding: 1px 6px;
  border: 1px solid var(--kant-interaktiv);
  border-radius: 4px;
  opacity: 0.75;
}
@media (max-width: 1023px) { #nav-search kbd { display: none; } }
@media (max-width: 767px) {
  #nav-search .sok-ord { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #nav-search { min-width: 40px; padding: 0; justify-content: center; }
  #nav-search::after { display: none; }
  #nav-search svg { width: 19px; height: 19px; }
  /* luppen tar plats — huvudet får inte bryta raden */
  .site-head nav a { white-space: nowrap; }
  .site-head .brand { line-height: 1.05; }
  .site-head nav { gap: 2px; }
}

.sok {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  background: rgba(20, 41, 31, 0.72); /* --verde-deep */
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(0px, 6vh, 72px) var(--space-2, 16px);
}
.sok.is-open { display: block; animation: sok-in var(--dur-reveal) var(--ease-ut) both; }
.sok.is-open .sok-panel { animation: sok-lyft var(--dur-move) var(--ease-ut) both; }
.sok--stilla.is-open, .sok--stilla.is-open .sok-panel { animation: none; }
@keyframes sok-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sok-lyft { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.sok-panel {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 44px) clamp(16px, 3vw, 28px);
}

.sok-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sok-eyebrow {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--brass-dark);
}
.sok-close {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  margin: -10px -10px 0 0;
  background: none; border: 0; border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-ut);
}
.sok-close svg { width: 16px; height: 16px; }
.sok-close:hover { background: var(--cream-dim); }

/* fältet: stor serif, en guldlinje under — som en rad i ett brev */
.sok-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  border-bottom: 2px solid var(--ink);
  transition: border-color var(--dur-micro) var(--ease-ut);
}
.sok-field:focus-within { border-color: var(--pomodoro); }
.sok-lupp { width: 26px; height: 26px; flex: none; color: var(--brass-dark); }
.sok-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.6rem, 4.4vw, 2.5rem);
  line-height: 1.2;
  padding: 10px 0 12px;
  letter-spacing: var(--track-tight);
}
.sok-input::placeholder { color: rgba(34, 30, 23, 0.38); }
.sok-input:focus { outline: none; }
.sok-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.sok-chips {
  display: flex;
  gap: 8px;
  margin: 18px 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.sok-chips::-webkit-scrollbar { display: none; }
.sok-chip {
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-ut), border-color var(--dur-micro) var(--ease-ut), color var(--dur-micro) var(--ease-ut);
}
.sok-chip:hover { border-color: var(--ink); }
.sok-chip[aria-pressed="true"] {
  background: var(--verde);
  border-color: var(--verde);
  color: var(--cream);
}
.sok-chip[aria-pressed="true"]::before { content: "✓ "; }

.sok-count {
  min-height: 1.4em;
  margin: 10px 0 4px;
  font-size: var(--text-xs);
  letter-spacing: var(--track-ui);
  text-transform: uppercase;
  color: var(--brass-dark);
}

.sok-list { list-style: none; margin: 0 -12px; padding: 0; }
.sok-item {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr 20px;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-tap) linear;
}
.sok-item + .sok-item::before {
  content: "";
  position: absolute;
  top: 0; left: 100px; right: 12px;
  border-top: 1px solid var(--hairline);
}
.sok-item[aria-selected="true"] { background: var(--cream); }
.sok-item[aria-selected="true"]::before, .sok-item[aria-selected="true"] + .sok-item::before { border-color: transparent; }
.sok-item[aria-selected="true"] .sok-pil { opacity: 1; transform: none; color: var(--pomodoro); }

.sok-thumb {
  width: 72px; height: 72px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--cream-dim);
}
.sok-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.sok-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sok-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.2;
}
.sok-sub { font-size: var(--text-sm); color: rgba(34, 30, 23, 0.72); }
.sok-why {
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sok-meta {
  margin-top: 3px;
  font-size: var(--text-xs);
  letter-spacing: var(--track-ui);
  text-transform: uppercase;
  color: var(--brass-dark);
}
.sok-text mark {
  background: none;
  color: inherit;
  box-shadow: inset 0 -0.42em 0 rgba(194, 58, 34, 0.18); /* --pomodoro, som en överstrykning */
  border-radius: 2px;
}
.sok-pil {
  width: 18px; height: 18px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--dur-micro) var(--ease-ut), transform var(--dur-micro) var(--ease-ut);
}

.sok-empty { padding: 18px 0 8px; }
.sok-hint { margin: 0 0 12px; font-size: var(--text-base); color: rgba(34, 30, 23, 0.8); }
.sok-hint em { font-family: var(--font-display); }
.sok-try { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; margin: 0; font-size: var(--text-sm); color: var(--brass-dark); }
.sok-try-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  text-decoration: underline;
  text-decoration-color: var(--pomodoro);
  text-underline-offset: 4px;
  cursor: pointer;
}
.sok-try-btn:hover { color: var(--pomodoro); }

.sok-keys {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  font-size: var(--text-xs);
  color: rgba(34, 30, 23, 0.6);
}
.sok-keys kbd {
  font: inherit;
  padding: 1px 6px;
  margin-right: 3px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: var(--paper);
}

.sok :focus-visible { outline: 2px solid var(--pomodoro); outline-offset: 2px; }
.sok .sok-input:focus, .sok .sok-input:focus-visible { outline: none; box-shadow: none; } /* linjen under fältet är fokusmarkeringen */

/* mobil: hela skärmen, listan får plats */
@media (max-width: 767px) {
  .sok { padding: 0; background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .sok-panel { min-height: 100%; border-radius: 0; box-shadow: none; padding-top: 14px; }
  .sok-keys { display: none; }
  .sok-item { grid-template-columns: 60px 1fr; gap: 12px; padding: 10px 12px; }
  .sok-item + .sok-item::before { left: 84px; }
  .sok-thumb { width: 60px; height: 60px; }
  .sok-pil { display: none; }
  .sok-name { font-size: 1.1rem; }
}

@media print { .sok { display: none !important; } }

/* smala telefoner (≤400 px): lite tajtare huvud så att luppen ryms */
@media (max-width: 400px) {
  .site-head { padding: 0 var(--space-1, 16px); }
  .site-head nav a { padding-left: 6px; padding-right: 6px; }
  #nav-news { padding: 0 12px; }
}
@media (max-width: 340px) {
  .site-head nav a[href="#today"] { display: none; } /* dagens recept är redan det första man ser */
}
