/* The Skiathos Guide — site search.
   A field in the masthead, a panel underneath it, a full sheet on a phone. */

.sitesearch {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
}

/* The masthead nav is already full at 1240px, so make room for the field
   rather than let the bar wrap onto two lines. Scoped to pages that
   actually carry a search field. */
.masthead .wrap:has(.sitesearch) nav { flex-wrap: nowrap; }
.masthead .wrap:has(.sitesearch) nav a { padding: 7px 8px; }
.masthead .wrap:has(.sitesearch) { gap: 14px; }

.ss-field {
  font-family: var(--font-sans);
  font-size: .84rem;
  font-weight: 500;
  color: var(--text);
  width: 170px;
  height: 38px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: var(--bg-alt);
  background-repeat: no-repeat;
  background-position: 13px 50%;
  background-size: 15px 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234d6b73' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
  transition: background-color .25s var(--ease),
              border-color .25s var(--ease), box-shadow .25s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.ss-field::placeholder { color: var(--text-soft); opacity: .85; }
.ss-field::-webkit-search-cancel-button { -webkit-appearance: none; }
.ss-field:focus {
  outline: none;
  border-color: var(--shallow);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--shallow) 26%, transparent);
}

/* On a photo hero the bar floats over the image, so the field goes glassy. */
body:has(.hero .ph-hero) .ss-field {
  background-color: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .34);
  color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}
body:has(.hero .ph-hero) .ss-field::placeholder { color: rgba(255, 255, 255, .78); }
html[data-scrolled="1"] body:has(.hero .ph-hero) .ss-field {
  background-color: var(--bg-alt);
  border-color: var(--line);
  color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234d6b73' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
}
html[data-scrolled="1"] body:has(.hero .ph-hero) .ss-field::placeholder { color: var(--text-soft); }

/* ------------------------------------------------------------ PANEL */

.ss-panel {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  width: min(560px, 76vw);
  max-height: min(70vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: 90;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
}
.sitesearch.is-open .ss-panel { display: block; }

.ss-lead, .ss-hint, .ss-empty {
  font-family: var(--font-mono);
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0;
  padding: 10px 14px 8px;
}
.ss-empty {
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-sans);
  font-size: .92rem;
  line-height: 1.5;
  padding: 22px 16px 24px;
  color: var(--text);
}
.ss-empty b { color: var(--bougie); font-weight: 600; }
.ss-hint {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding: 10px 14px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.ss-key {
  font-family: var(--font-mono);
  font-size: .62rem;
  text-transform: none;
  letter-spacing: .02em;
  color: var(--text-soft);
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  margin-right: 2px;
}

.ss-list { display: block; }

.ss-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: background .18s var(--ease);
}
.ss-item + .ss-item { margin-top: 1px; }
.ss-item.is-sel, .ss-item:focus-visible {
  background: var(--bg-sunk);
  outline: none;
}
.ss-item.is-sel .ss-title { color: var(--aegean); }

.ss-kind {
  flex: none;
  font-family: var(--font-mono);
  font-size: .58rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--pine);
  background: color-mix(in srgb, var(--shallow) 20%, transparent);
  border-radius: 999px;
  padding: 5px 9px;
  margin-top: 2px;
  white-space: nowrap;
}

.ss-body { min-width: 0; display: block; }
.ss-title {
  display: block;
  font-family: var(--font-sans);
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.ss-title mark {
  background: var(--sandy);
  color: inherit;
  border-radius: 3px;
  box-shadow: 0 0 0 2px var(--sandy);
}
.ss-desc {
  display: block;
  font-family: var(--font-sans);
  font-size: .8rem;
  line-height: 1.45;
  color: var(--text-soft);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ss-close { display: none; }
.ss-backdrop { display: none; }
.ss-live {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Dark mode: the tint behind a kind label needs more light to read. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ss-kind { color: var(--shallow); }
  :root:not([data-theme="light"]) .ss-title mark {
    background: color-mix(in srgb, var(--shallow) 30%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--shallow) 30%, transparent);
  }
}
:root[data-theme="dark"] .ss-kind { color: var(--shallow); }
:root[data-theme="dark"] .ss-title mark {
  background: color-mix(in srgb, var(--shallow) 30%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--shallow) 30%, transparent);
}

/* ------------------------------------------------------------ PHONE */

/* Below this the nav has no room left, so the field becomes a tap target
   and opens as a sheet. */
@media (max-width: 1180px) {
  /* Collapsed to a tap target in the bar. The hero rules above are more
     specific, so the collapsed state has to match their weight. */
  .ss-field,
  body:has(.hero .ph-hero) .ss-field,
  html[data-scrolled="1"] body:has(.hero .ph-hero) .ss-field {
    width: 38px;
    max-width: 38px;
    padding: 0;
    color: transparent;
    background-position: 50% 50%;
    background-size: 17px 17px;
    cursor: pointer;
  }
  .ss-field::placeholder,
  body:has(.hero .ph-hero) .ss-field::placeholder,
  html[data-scrolled="1"] body:has(.hero .ph-hero) .ss-field::placeholder { color: transparent; }
  .ss-field:focus { box-shadow: none; }

  /* Tapped, it becomes a sheet across the top of the screen. */
  .sitesearch.is-open {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 200;
    display: block;
    padding: 12px max(14px, calc((100vw - 1180px) / 2)) 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
  }
  .sitesearch.is-open .ss-field,
  html[data-scrolled="1"] body:has(.hero .ph-hero) .sitesearch.is-open .ss-field,
  body:has(.hero .ph-hero) .sitesearch.is-open .ss-field {
    width: calc(100% - 74px);
    max-width: none;
    height: 44px;
    padding: 0 14px 0 40px;
    font-size: 16px;              /* stops iOS zooming in on focus */
    color: var(--text);
    background-color: var(--bg-alt);
    background-position: 14px 50%;
    background-size: 16px 16px;
    border-color: var(--line);
    cursor: text;
  }
  .sitesearch.is-open .ss-field::placeholder,
  body:has(.hero .ph-hero) .sitesearch.is-open .ss-field::placeholder,
  html[data-scrolled="1"] body:has(.hero .ph-hero) .sitesearch.is-open .ss-field::placeholder {
    color: var(--text-soft);
  }

  .sitesearch.is-open .ss-close {
    display: inline-block;
    position: absolute;
    right: max(14px, calc((100vw - 1180px) / 2));
    top: 12px;
    height: 44px;
    padding: 0 4px;
    border: 0;
    background: none;
    font-family: var(--font-sans);
    font-size: .86rem;
    font-weight: 600;
    color: var(--aegean);
    cursor: pointer;
  }

  .sitesearch.is-open .ss-panel {
    position: static;
    width: auto;
    margin-top: 10px;
    max-height: calc(100vh - 110px);
    max-height: calc(100dvh - 110px);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: none;
    padding: 0;
  }

  /* The masthead owns a stacking context, and the sheet lives inside it, so
     lift the whole bar above the backdrop rather than the sheet alone. */
  html[data-search="open"] .masthead { z-index: 210; }

  html[data-search="open"] .ss-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(10, 58, 71, .38);
    backdrop-filter: blur(2px);
  }

  .ss-item { padding: 12px 6px; gap: 10px; }
}

@media (max-width: 760px) {
  .ss-kind { font-size: .55rem; padding: 4px 7px; }
  .ss-title { font-size: .94rem; }
  .ss-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ss-field, .ss-item { transition: none; }
}

@media print { .sitesearch, .ss-backdrop { display: none !important; } }
