/* Shared header/footer — mirrors SPA (TasuketagApp / tasuketag.css) */

:root {
  --tt-ink: #14212b;
  --tt-sea: #0f6e7a;
  --tt-sea-deep: #0a4a54;
  --tt-sand: #f3ebe0;
  --tt-foam: #fffaf4;
  --tt-mint: #2a9d8f;
  --tt-line: rgba(20, 33, 43, 0.12);
  --tt-muted: rgba(20, 33, 43, 0.62);
  --tt-font: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
  --tt-display: "Zen Maru Gothic", "Zen Kaku Gothic New", sans-serif;
  --tt-safe-top: env(safe-area-inset-top, 0px);
  --tt-safe-right: env(safe-area-inset-right, 0px);
  --tt-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tt-safe-left: env(safe-area-inset-left, 0px);
  --chrome-max: 720px;
}

/* ——— Header (SPA .tt-top / .tt-brand) ——— */
.site-top {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(12px + var(--tt-safe-top)) max(16px, var(--tt-safe-right)) 12px max(16px, var(--tt-safe-left));
  background:
    linear-gradient(
      180deg,
      rgba(232, 244, 243, 0.94) 0%,
      rgba(243, 235, 224, 0.9) 100%
    );
  border-bottom: 1px solid var(--tt-line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.site-top__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  max-width: var(--chrome-max);
  margin: 0 auto;
  min-width: 0;
  width: 100%;
}

.site-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: var(--tt-sea-deep);
  min-width: 0;
  flex: 0 1 auto;
  max-width: min(36em, 100%);
}

.site-brand__en {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--tt-muted);
  line-height: 1.2;
  font-family: var(--tt-font);
}

.site-brand__ja {
  font-family: var(--tt-display);
  font-weight: 700;
  font-size: clamp(1.25rem, 3.5vw, 1.75rem);
  letter-spacing: 0.04em;
  line-height: 1.1;
  color: var(--tt-sea-deep);
}

.site-brand__tagline {
  margin: 0;
  font-family: var(--tt-font);
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--tt-ink);
  opacity: 0.85;
  max-width: 36em;
}

.site-top__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-width: 0;
  margin-left: auto;
}

.site-top__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.site-top__nav a {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--tt-line);
  background: rgba(255, 250, 244, 0.75);
  color: var(--tt-ink);
  font-family: var(--tt-font);
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.site-top__nav a:hover {
  background: #fff;
  border-color: rgba(15, 110, 122, 0.35);
}

.site-top__nav a.is-primary {
  background: var(--tt-sea);
  color: #fff;
  border-color: var(--tt-sea);
  font-weight: 700;
}

.site-top__nav a.is-primary:hover {
  background: var(--tt-sea-deep);
}

/* Lang toggle — SPA .tt-lang */
.site-lang {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 2px;
  border: 1px solid var(--tt-line);
  border-radius: 999px;
  padding: 2px;
  background: rgba(255, 250, 244, 0.85);
  flex-shrink: 0;
  width: auto;
  max-width: max-content;
}

.site-lang__btn {
  border: 0;
  background: transparent;
  color: var(--tt-muted);
  font-family: var(--tt-font);
  font-size: 0.75rem;
  font-weight: 600;
  min-height: 36px;
  min-width: 2.5rem;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  flex: 0 0 auto;
}

.site-lang__btn.is-active,
.site-lang__btn[aria-pressed="true"] {
  background: var(--tt-ink);
  color: #fff;
}

/* ——— Footer (SPA .tt-page-footer) ——— */
.site-foot {
  margin-top: 28px;
  padding: 16px max(16px, var(--tt-safe-right)) calc(16px + var(--tt-safe-bottom)) max(16px, var(--tt-safe-left));
  border-top: 1px solid var(--tt-line);
  color: var(--tt-muted);
  font-family: var(--tt-font);
  font-size: 0.78rem;
  line-height: 1.45;
  background: transparent;
  overflow-x: clip;
}

.site-foot__inner {
  width: min(var(--chrome-max), 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.site-foot__brand {
  margin: 0 0 0.85rem;
  font-family: var(--tt-display);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  color: var(--tt-sea-deep);
  text-align: center;
}

.site-foot__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1.1rem;
  margin-bottom: 0.85rem;
  text-align: left;
}

@media (min-width: 640px) {
  .site-foot__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.site-foot__col {
  margin: 0;
  min-width: 0;
}

.site-foot__h {
  margin: 0 0 0.35rem;
  font-family: var(--tt-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--tt-muted);
}

.site-foot__col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.site-foot__col a {
  color: var(--tt-sea-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  overflow-wrap: anywhere;
}

.site-foot__note {
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--tt-muted);
  line-height: 1.5;
}

.site-foot__lang {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

/* LP uses wider chrome */
body.lp-body {
  --chrome-max: 1120px;
}

/*
 * Tools / request (not LP): on desktop, pin brand far left and nav far right
 * across the full header width (page content stays --chrome-max).
 */
@media (min-width: 640px) {
  body:not(.lp-body) .site-top__inner {
    max-width: none;
    width: 100%;
    align-items: flex-end;
    justify-content: space-between;
  }

  body:not(.lp-body) .site-brand {
    flex: 0 1 auto;
  }

  body:not(.lp-body) .site-top__actions {
    margin-left: auto;
    flex: 0 0 auto;
  }
}

/*
 * Phone: brand + lang stay one row (no awkward JA/EN wrap);
 * nav CTAs (when present) take the full next row — tools mobile stays good.
 */
@media (max-width: 639px) {
  .site-top {
    padding: calc(10px + var(--tt-safe-top)) max(12px, var(--tt-safe-right)) 10px max(12px, var(--tt-safe-left));
  }

  .site-top__inner {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 12px;
    justify-content: space-between;
  }

  .site-brand {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 6.5rem);
  }

  .site-brand__ja {
    font-size: clamp(1.15rem, 5vw, 1.4rem);
  }

  .site-brand__en {
    letter-spacing: 0.16em;
  }

  .site-brand__tagline {
    font-size: 0.75rem;
    line-height: 1.35;
  }

  /* Let lang + nav participate in the header flex row/wrap */
  .site-top__actions {
    display: contents;
  }

  .site-lang {
    flex: 0 0 auto;
    margin-left: auto;
    align-self: flex-start;
  }

  .site-top__nav {
    flex: 1 1 100%;
    width: 100%;
    order: 3;
    justify-content: flex-start;
  }

  .site-top__nav a {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px;
    font-size: 0.82rem;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }

  .site-foot__grid {
    gap: 1rem 0.85rem;
  }
}

@media (max-width: 379px) {
  .site-top__nav a {
    font-size: 0.78rem;
    padding: 8px 8px;
  }

  .site-lang__btn {
    min-width: 2.25rem;
    padding: 6px 8px;
    font-size: 0.72rem;
  }

  .site-foot__col a {
    font-size: 0.78rem;
  }
}
