/* billjalouk.com, the language switch. Plain CSS, no build step. Loaded by every page after its own stylesheet.
   Look chosen by Bill on 2026-11-13: the language in use with its small flag, set in the door's corner
   brackets. A click opens a small card, in the family of the homepage cards, with the languages to choose from.
   The markup comes from tools/lang/lang.js. It is a details element with plain links inside, so it opens,
   closes and switches without scripts. Flags: public/assets/flags/, from flag-icons 7.5.0 (MIT). */

/* The Arabic font: IBM Plex Sans Arabic, weights 300 and 700, self-hosted (Fontsource 5.3.0, SIL Open Font
   License, licence text beside the files). Chosen by Bill on 2026-11-13. Arabic letters only: Latin letters and
   digits stay in Fraunces. It is declared here because the card names Arabic on every page. A browser fetches a
   font only when text on the screen needs it: on an English or German page that is when the card is opened. */
@font-face {
  font-family: "IBM Plex Sans Arabic"; src: url(/assets/fonts/ibm-plex-sans-arabic-300.woff2) format("woff2");
  font-weight: 300; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "IBM Plex Sans Arabic"; src: url(/assets/fonts/ibm-plex-sans-arabic-700.woff2) format("woff2");
  font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
/* the Arabic name in the card, on a page of another language */
.lang-item:lang(ar) { font-family: var(--font), "IBM Plex Sans Arabic", serif; }

.lang { position: absolute; z-index: 30; }
/* homepage: top left, the twin of the door at top right. Sub-pages: top right, opposite the name. */
.lang-home { top: calc(var(--pad) * 0.6); left: calc(var(--pad) * 0.8 + env(safe-area-inset-left, 0px)); z-index: 6; }
.lang-sub { top: 8px; right: calc(var(--pad) - 6px + env(safe-area-inset-right, 0px)); }

/* the door's pair of brackets, mirrored: top right and bottom left */
.lang-frame { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.lang-frame path {
  fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; vector-effect: non-scaling-stroke;
  stroke-dasharray: 1; stroke-dashoffset: var(--lang-frame, 0);
  opacity: 0.7; transition: opacity 0.3s var(--ease-out);
}

/* closed: the language in use */
.lang-d summary {
  display: flex; align-items: center; gap: 9px; min-width: 44px; min-height: 44px; padding: 0 14px;
  list-style: none; cursor: pointer;
  font-size: 14px; line-height: 1; white-space: nowrap; hyphens: manual;
  color: var(--muted); transition: color 0.3s var(--ease-out);
}
.lang-d summary::-webkit-details-marker { display: none; }
/* a small corner beside the word: this opens. It turns over when open. */
.lang-d summary::after {
  content: ""; flex: none; width: 5px; height: 5px; margin-left: 1px;
  border-right: 1px solid currentColor; border-bottom: 1px solid currentColor;
  transform: translateY(-2px) rotate(45deg); opacity: 0.75; transition: transform 0.25s var(--ease-out);
}
.lang-d[open] summary::after { transform: translateY(1px) rotate(225deg); }

/* the flags are quiet until they are in use or touched. The hairline keeps the black of the German flag visible. */
.lang-flag {
  display: block; flex: none; width: 16px; height: 12px; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(241, 238, 249, 0.25); opacity: 0.72; transition: opacity 0.3s var(--ease-out);
}

/* open: a card under the word, with the rose bar of the homepage cards */
.lang-menu {
  position: absolute; top: 50px; min-width: 100%; padding: 2px 0;
  border: 1px solid rgba(241, 238, 249, 0.14); border-radius: var(--radius);
  background: rgba(14, 13, 24, 0.96);
}
.lang-home .lang-menu { left: 0; }
.lang-sub .lang-menu { right: 0; }
.lang-menu::before { content: ""; position: absolute; left: -1px; top: 12px; width: 2px; height: 20px; background: var(--accent); }
.lang-item {
  display: flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 14px;
  font-size: 14px; line-height: 1; white-space: nowrap; hyphens: manual;
  color: var(--muted); transition: color 0.3s var(--ease-out);
}
/* the language in use: bright, with a rose point */
.lang-item.is-on { color: var(--ink); }
.lang-item.is-on::after {
  content: ""; width: 4px; height: 4px; margin-left: auto; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px color-mix(in oklab, var(--accent) 80%, transparent);
}

.lang-d[open] summary, .lang-d summary:focus-visible, a.lang-item:focus-visible { color: var(--ink); }
.lang-d[open] summary .lang-flag, .lang-item.is-on .lang-flag, .lang-d summary:focus-visible .lang-flag, a.lang-item:focus-visible .lang-flag { opacity: 1; }
.lang:focus-within .lang-frame path, .lang:has(.lang-d[open]) .lang-frame path { opacity: 1; }
@media (hover: hover) {
  .lang-d summary:hover, a.lang-item:hover { color: var(--ink); }
  .lang-d summary:hover .lang-flag, a.lang-item:hover .lang-flag { opacity: 1; }
  .lang:hover .lang-frame path { opacity: 1; }
}

/* homepage: an agent draws the two brackets (--lang-frame 1 to 0), then writes the flag and the word from left
   to right (--lang-in 0 to 1), while another agent draws the door. home.js drives both values.
   On a phone no agent comes for it, as for the door: the switch is complete when the page has arrived.
   nojs.css completes it when scripts are off. */
html:not(.arrived) .lang-home { --lang-frame: 1; --lang-in: 0; }
html:not(.arrived) .lang-home summary { clip-path: inset(-6px calc((1 - var(--lang-in)) * 100%) -6px -6px); pointer-events: none; }

/* German: long words may break at a syllable, and never push a box wider than the screen */
:lang(de) p, :lang(de) li, :lang(de) dd, :lang(de) dt, :lang(de) h2, :lang(de) h3, :lang(de) figcaption {
  hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word;
}

/* German words are longer than the English ones the pages were laid out for. Four places need more room. */
/* Skills, tool lists: wider columns, so a long word stays whole. On a phone the list becomes one column. */
:lang(de) .tools { columns: 190px 2; }
/* Skills, names beside the pile: the full names fit only beside a wide pile. Otherwise the short names. */
@container (max-width: 639px) { :lang(de) .n-long { display: none; } :lang(de) .n-short { display: inline; } }
/* Projects, the two labels before the facts: "Mein Anteil" needs more width than "My part" */
:lang(de) .p-fact { grid-template-columns: 76px minmax(0, 1fr); }

@media (prefers-reduced-motion: reduce) {
  .lang-home { --lang-frame: 0 !important; --lang-in: 1 !important; }
  .lang-home summary { clip-path: none !important; pointer-events: auto !important; }
  .lang-d summary, .lang-d summary::after, .lang-item, .lang-flag, .lang-frame path { transition: none !important; }
}
