/* ==========================================================================
   Mini Xcode : éditeur Swift avec frappe animée + simulateur iPhone 15 Pro
   ========================================================================== */

.xcode {
  /* Palette inspirée du thème « Default (Light) » d'Xcode */
  --xcode-bg: #fff;
  --xcode-fg: #000;
  --xcode-border: #0000001f;
  --xcode-toolbar: #f0f0f5;
  --xcode-gutter: #a0a0aa;
  --xcode-muted: #6e6e78;
  --xcode-success: #1c8f3a;
  --xcode-button: #e5e5ea;
  --xcode-button-hover: #d4d4da;
  --syntax-keyword: #ad3da4;
  --syntax-string: #d12f1b;
  --syntax-type: #3e8087;
  --syntax-sdk: #6c36a9;
  --syntax-number: #272ad8;
  --syntax-comment: #707f8c;
  --syntax-declaration: #0f68a0;
  --syntax-usage: #326d74;

  grid-column: span 5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px;
  border-color: var(--xcode-border);
  background: var(--xcode-bg);
  color: var(--xcode-fg);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .xcode {
    --xcode-bg: #1f1f24;
    --xcode-fg: #f2f2f7;
    --xcode-border: #ffffff1f;
    --xcode-toolbar: #2a2a30;
    --xcode-gutter: #5b5c66;
    --xcode-muted: #a9a9b3;
    --xcode-success: #7ee787;
    --xcode-button: #34343c;
    --xcode-button-hover: #4d4d58;
    --syntax-keyword: #fc5fa3;
    --syntax-string: #fc6a5d;
    --syntax-type: #5dd8ff;
    --syntax-sdk: #d0a8ff;
    --syntax-number: #d0bf69;
    --syntax-comment: #6c7986;
    --syntax-declaration: #41a1c0;
    --syntax-usage: #67b7a4;
  }
}

:root[data-theme="dark"] .xcode {
  --xcode-bg: #1f1f24;
  --xcode-fg: #f2f2f7;
  --xcode-border: #ffffff1f;
  --xcode-toolbar: #2a2a30;
  --xcode-gutter: #5b5c66;
  --xcode-muted: #a9a9b3;
  --xcode-success: #7ee787;
  --xcode-button: #34343c;
  --xcode-button-hover: #4d4d58;
  --syntax-keyword: #fc5fa3;
  --syntax-string: #fc6a5d;
  --syntax-type: #5dd8ff;
  --syntax-sdk: #d0a8ff;
  --syntax-number: #d0bf69;
  --syntax-comment: #6c7986;
  --syntax-declaration: #41a1c0;
  --syntax-usage: #67b7a4;
}

.xcode-window {
  width: 100%;
}

/* ---- Barre d'outils ---- */
.xcode-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.window-controls {
  display: flex;
  gap: 7px;
}

.run-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: var(--xcode-button);
  color: var(--xcode-fg);
  font-size: 10px;
}

.run-button:hover {
  background: var(--xcode-button-hover);
}

.xcode-status {
  flex: 1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  overflow: hidden;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--xcode-toolbar);
  color: var(--xcode-muted);
  font: 500 10.5px var(--font-mono);
  white-space: nowrap;
}

.xcode-scheme {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.xcode-scheme-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.build-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: -4px;
  padding: 0;
  border-radius: 5px;
  background: var(--color-system-blue);
  color: #000;
  cursor: pointer;
  transition: filter 0.2s;
}

.build-button:hover {
  background: var(--color-system-blue);
  filter: brightness(1.15);
}

.build-button svg {
  width: 13px;
  height: 13px;
  overflow: visible;
  fill: currentColor;
}

.build-status {
  flex: none;
}

.build-success {
  color: var(--xcode-success);
  transition: opacity 0.4s;
}

.build-success.is-fading {
  opacity: 0;
}

.spinner {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border: 2px solid #666;
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.7s linear infinite;
}

/* ---- Onglets de fichiers ---- */
.xcode-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--xcode-border);
  scrollbar-width: none;
}

.xcode-tabs::-webkit-scrollbar {
  display: none;
}

.xcode-tabs button {
  flex: none;
  padding: 7px 9px;
  border-radius: 7px 7px 0 0;
  background: transparent;
  color: var(--xcode-muted);
  font: 500 11px var(--font-mono);
}

.xcode-tabs button:hover,
.xcode-tabs button.is-active {
  background: var(--xcode-toolbar);
  color: var(--xcode-fg);
}

/* ---- Éditeur ---- */
.xcode-editor {
  position: relative;
  display: flex;
  gap: 14px;
  height: 374px;
  overflow: hidden;
  padding: 12px 4px 0;
}

.line-numbers,
.code-view {
  margin: 0;
  font: 500 11px/1.75 var(--font-mono);
  white-space: pre;
}

.line-numbers {
  min-width: 2ch;
  overflow: hidden;
  color: var(--xcode-gutter);
  text-align: right;
}

.code-view {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--xcode-gutter) transparent;
}

/* Coloration syntaxique (classes générées par highlightSwift) */
.tok-keyword {
  color: var(--syntax-keyword);
  font-weight: 700;
}

.tok-declaration {
  color: var(--syntax-declaration);
}

.tok-usage {
  color: var(--syntax-usage);
}

.tok-string {
  color: var(--syntax-string);
}

.tok-type {
  color: var(--syntax-type);
}

.tok-sdk {
  color: var(--syntax-sdk);
}

.tok-number {
  color: var(--syntax-number);
}

.tok-comment {
  color: var(--syntax-comment);
}

.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 1.1em;
  background: var(--xcode-fg);
  vertical-align: -0.2em;
  animation: blink 1s steps(2) infinite;
}

/* ---- Suggestions d'autocomplétion ---- */
.autocomplete {
  position: absolute;
  left: 84px;
  bottom: 12px;
  min-width: 200px;
  padding: 4px;
  border: 1px solid var(--xcode-border);
  border-radius: 9px;
  background: var(--xcode-toolbar);
  color: var(--xcode-fg);
  font: 500 11px var(--font-mono);
  box-shadow: 0 12px 30px #0003;
  opacity: 0;
  translate: 0 8px;
  pointer-events: none;
  transition: 0.35s;
}

.autocomplete.is-visible {
  opacity: 1;
  translate: 0;
}

.autocomplete div {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  border-radius: 6px;
}

.autocomplete div.is-selected {
  background: #0a64ff;
  color: #fff;
}

.autocomplete i {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #8a5cf6;
  color: #fff;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
}

.autocomplete em {
  margin-left: auto;
  font-style: normal;
  opacity: 0.65;
}

/* ==========================================================================
   Simulateur : iPhone 15 Pro (cadre titane, Dynamic Island, barre d'état)
   ========================================================================== */

.simulator {
  position: absolute;
  right: 8px;
  bottom: -340px;
  width: 158px;
  height: 320px;
  padding: 4px;
  border-radius: 32px;
  background: linear-gradient(145deg, #6a6a6f, #cfcfd4 38%, #8d8d92 66%, #5d5d62);
  color: #000;
  text-align: center;
  transition: bottom 0.7s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.simulator.is-running {
  bottom: 8px;
}

.sim-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 2px solid #000;
  border-radius: 28px;
  background: #fff;
  color: #000;
  text-align: center;
}

.dynamic-island {
  position: absolute;
  z-index: 3;
  top: 9px;
  left: 50%;
  translate: -50% 0;
  width: 52px;
  height: 16px;
  border-radius: 12px;
  background: #000;
}

.status-bar {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  font: 700 9px var(--font-sans);
}

.status-bar svg {
  fill: currentColor;
}

.status-bar-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-bar-icons svg + svg {
  margin-left: -2px;
}

.sim-home-indicator {
  position: absolute;
  z-index: 3;
  bottom: 5px;
  left: 50%;
  translate: -50% 0;
  width: 46px;
  height: 4px;
  border-radius: 4px;
  background: currentColor;
}

/* Boutons latéraux : Action, volume +, volume −, alimentation */
.sim-button {
  position: absolute;
  width: 3px;
  border-radius: 2px;
  background: #7d7d83;
}

.sim-button--action {
  left: -2px;
  top: 62px;
  height: 14px;
}

.sim-button--volume-up {
  left: -2px;
  top: 88px;
  height: 26px;
}

.sim-button--volume-down {
  left: -2px;
  top: 120px;
  height: 26px;
}

.sim-button--power {
  right: -2px;
  top: 104px;
  height: 42px;
}

/* ---- DeveloperView.swift ---- */
.sim-flag {
  font-size: 44px;
  line-height: 1;
}

.sim-name {
  font-size: 15px;
}

.sim-role {
  font-size: 14px;
}

.sim-screen small {
  color: #000;
  font-size: 10.5px;
}

.sim-screen small.sim-years {
  font-size: 9.5px;
}

/* ---- CareerView.swift : liste + push « 404 » ---- */
.simulator.is-list .sim-screen {
  justify-content: flex-start;
  align-items: stretch;
  gap: 0;
  padding-top: 46px;
  background: #f2f2f7;
  text-align: left;
}

.sim-list {
  margin: 0 8px;
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
}

.sim-list > a,
.sim-list > button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #e5e5ea;
  border-radius: 0;
  background: #fff;
  color: #000;
  font: 400 10.5px var(--font-sans);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.sim-list > :last-child {
  border-bottom: 0;
}

.sim-list > a:hover,
.sim-list > button:hover {
  background: #e9e9ee;
}

.sim-list i {
  color: #c4c4c9;
  font-size: 12px;
  font-style: normal;
}

.sim-push {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #f2f2f7;
  color: #000;
  box-shadow: -8px 0 20px #0002;
  translate: 100% 0;
  transition: translate 0.38s var(--ease-out);
}

.sim-push.is-visible {
  translate: 0;
}

.sim-back {
  position: absolute;
  top: 32px;
  left: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  background: transparent;
  color: #007aff;
  font: 500 10.5px var(--font-sans);
}

.sim-back:hover {
  background: #007aff14;
}

.sim-push-title {
  position: absolute;
  top: 56px;
  left: 12px;
  right: 12px;
  font: 700 17px/1.1 var(--font-sans);
  letter-spacing: -0.02em;
  pointer-events: none;
}

.sim-push svg {
  width: 62px;
  height: 62px;
  margin-bottom: 6px;
  fill: none;
  stroke: #000;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sim-push strong {
  font: 800 30px/1 var(--font-mono);
  letter-spacing: -0.04em;
}

.sim-push span {
  color: #6e6e73;
  font: 500 10px var(--font-sans);
}

/* ---- PlayerView.swift : vrai lecteur HLS ---- */
.simulator.is-video .sim-screen {
  padding: 0;
  background: #000;
}

.simulator.is-video .status-bar,
.simulator.is-video .sim-home-indicator {
  color: #fff;
}

/* Mire de barres couleur affichée avant le chargement de la vidéo */
.sim-color-bars {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 124px;
  translate: 0 -50%;
  background: linear-gradient(
    90deg,
    #c0c0c0 0 14.3%,
    #c0c000 0 28.6%,
    #00c0c0 0 42.9%,
    #00c000 0 57.2%,
    #c000c0 0 71.5%,
    #c00000 0 85.8%,
    #0000c0 0
  );
}

.simulator video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}

.sim-controls {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 44px 12px 12px;
  background: linear-gradient(#0008, transparent 30%, transparent 65%, #000a);
  color: #fff;
}

.sim-controls > div {
  width: 100%;
  text-align: left;
}

.sim-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #0008;
  color: #fff;
  cursor: pointer;
}

.sim-play:hover {
  background: #000b;
}

.sim-play:focus-visible {
  outline: 2px solid var(--color-system-blue);
}

/* Icône pause : deux barres */
.sim-play s {
  width: 4px;
  height: 15px;
  border-radius: 2px;
  background: #fff;
  text-decoration: none;
}

/* Icône lecture : triangle */
.sim-play.is-paused s {
  display: none;
}

.sim-play.is-paused::before {
  content: "";
  margin-left: 3px;
  border-left: 13px solid #fff;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.sim-scrubber {
  height: 3px;
  margin-bottom: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: #ffffff55;
  cursor: pointer;
}

.sim-scrubber u {
  display: block;
  width: 0;
  height: 100%;
  background: #fff;
  text-decoration: none;
}

.sim-time {
  color: #fff;
  font: 600 9px var(--font-sans);
}

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .xcode {
    grid-column: span 12;
  }
}
