/* Language menu, footer languages and the language suggestion.
   Paper and ink palette; see includes/i18n.php. */

body .stw-lang {
    position: relative;
    margin-inline-start: 14px;
    font-family: var(--sans, 'Inter', system-ui, sans-serif);
    flex: none;
}
body .stw-lang > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 7px 10px;
    border: 1px solid var(--line, #E3D9C8);
    border-radius: 8px;
    color: var(--ink-soft, #5C6270);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    user-select: none;
    background: transparent;
}
/* The menu joins the right-hand group instead of splitting the header in three. */
body .nav:has(> .stw-lang) > a:first-child { margin-inline-end: auto; }
body .stw-lang > summary::-webkit-details-marker { display: none; }
body .stw-lang > summary::marker { content: ''; }
body .stw-lang > summary:hover,
body .stw-lang[open] > summary { color: var(--ink, #1C2230); border-color: var(--ink-faint, #9A9CA3); }
body .stw-lang > summary:focus-visible { outline: 2px solid var(--coral, #EE5234); outline-offset: 2px; }

body .stw-lang-menu {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 8px);
    z-index: 1001;
    min-width: 200px;
    max-height: min(70vh, 520px);
    overflow-y: auto;
    background: var(--card, #FFFCF6);
    border: 1px solid var(--line, #E3D9C8);
    border-radius: 12px;
    box-shadow: 0 22px 48px -22px rgba(28, 34, 48, 0.45);
    padding: 6px;
    display: grid;
    gap: 1px;
}
body .stw-lang-menu a {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--ink, #1C2230);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.3;
    text-align: start;
}
body .stw-lang-menu a::after { display: none; }
body .stw-lang-menu a:hover { background: var(--paper, #F4EEE3); color: var(--ink, #1C2230); }
body .stw-lang-menu a[aria-current] { font-weight: 700; background: var(--note, #F8E6A8); }

/* Footer: one quiet row of language names. */
body .stw-lang-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    max-width: 1200px;
    margin: 6px auto 18px;
    padding: 16px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
}
body .stw-lang-foot a { color: #AFB8C6; text-decoration: none; }
body .stw-lang-foot a:hover { color: var(--highlight, #FFD95A); }
body .stw-lang-foot a[aria-current] { color: #fff; font-weight: 600; }

/* "This page is available in ..." - suggested, never forced. */
.stw-lang-hint {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 1002;
    max-width: min(470px, calc(100vw - 32px));
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--ink, #1C2230);
    color: #fff;
    border-radius: 14px;
    padding: 12px 12px 12px 16px;
    box-shadow: 0 22px 48px -18px rgba(28, 34, 48, 0.6);
    font: 500 0.92rem/1.35 var(--sans, 'Inter', system-ui, sans-serif);
    animation: stw-lang-in 0.25s ease-out;
}
.stw-lang-hint[dir="rtl"] { left: auto; right: 16px; padding: 12px 16px 12px 12px; }
.stw-lang-hint p { margin: 0; color: #fff; flex: 1; }
.stw-lang-hint a.stw-lang-go {
    flex: none;
    background: var(--coral, #EE5234);
    color: #fff;
    border-radius: 9px;
    padding: 8px 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.stw-lang-hint a.stw-lang-go:hover { background: var(--coral-deep, #D8401F); color: #fff; }
.stw-lang-hint button {
    flex: none;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.stw-lang-hint button:hover { background: rgba(255, 255, 255, 0.2); }
@keyframes stw-lang-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Legal pages in another language: the note above the English text. */
body .stw-i18n-note {
    max-width: 900px;
    margin: 24px auto 0;
    padding: 12px 16px;
    background: var(--note, #F8E6A8);
    border-radius: 10px;
    color: #5A4408;
    font-size: 0.95rem;
}

/* Scripts the site fonts do not cover. */
html:lang(ja) body { font-family: 'Inter', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', Meiryo, sans-serif; }
html:lang(ja) h1, html:lang(ja) h2, html:lang(ja) h3 { letter-spacing: 0 !important; }

/* Longer words in other languages: header links stay on one line; between
   the phone menu and a wide screen the tagline steps aside and gaps shrink. */
@media (min-width: 769px) {
    body .nav:has(> .stw-lang) .nav-links a,
    body .nav:has(> .stw-lang) .tagline { white-space: nowrap; }
}
@media (min-width: 769px) and (max-width: 1000px) {
    body .nav:has(> .stw-lang) .tagline { display: none !important; }
    body .nav:has(> .stw-lang) .nav-links { gap: 18px; }
}
@media (min-width: 769px) and (max-width: 1240px) {
    html:not([lang="en"]) body .nav:has(> .stw-lang) .tagline { display: none !important; }
    html:not([lang="en"]) body .nav:has(> .stw-lang) .nav-links { gap: 18px; }
    html:not([lang="en"]) body .nav:has(> .stw-lang) .stw-lang { margin-inline-start: 10px; }
}
@media (min-width: 769px) and (max-width: 940px) {
    html:not([lang="en"]) body .nav:has(> .stw-lang) .nav-links { gap: 12px; }
    html:not([lang="en"]) body .nav:has(> .stw-lang) .nav-links a { font-size: 0.9rem; }
    html:not([lang="en"]) body .nav:has(> .stw-lang) .nav-links a.stw-nav-yt::before { display: none; }
}

@media (max-width: 768px) {
    /* Next to the menu button on phones, so the language is always one tap away. */
    body .nav > .stw-lang { order: 2; margin-inline-end: 10px; }
    body .nav > .menu-toggle { order: 3; }
    body .stw-lang > summary { padding: 7px 8px; }
    .stw-lang-hint { left: 12px; right: 12px; bottom: 12px; max-width: none; }
    .stw-lang-hint[dir="rtl"] { left: 12px; right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .stw-lang-hint { animation: none; }
}
