/* Navigation de la ferme. Le décor Three.js reste dimensionné au viewport. */
.farm-entry-shell { display: none; }
body.world-loading .farm-entry-shell {
  position: fixed;
  inset: 0;
  z-index: 3200;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background-color: #203c30;
}
#farm-site-navigation { position: relative; z-index: 2; min-width: 0; }
body[data-farm-stage="visiting"] #farm-site-navigation { display: none; }
.farm-entry-shell #world-loader {
  position: relative;
  z-index: 1;
  grid-row: 2;
  min-height: 0;
  inset: auto;
}
body[data-farm-stage="visiting"] .farm-entry-shell #world-loader { grid-row: 1 / -1; }
.farm-entry-shell #world-loader::before { position: absolute; }
.farm-entry-shell #world-loader #world-loader-enter { position: absolute; }
.farm-noscript { margin: auto; padding: 18px; color: #fbf1de; font: 1rem/1.55 system-ui, sans-serif; }
.farm-noscript a { color: inherit; }
body.world-loading > :not(.farm-entry-shell):not(script):not(link):not(style):not(noscript) { visibility: hidden; }

#farm-game-header {
  --farm-bar-cream: #f7f1df;
  --farm-bar-gold: #d8bd86;
  --farm-bar-line: #c8aa705c;
  --farm-bar-height: 66px;
  position: absolute;
  inset: 0 0 auto;
  color: var(--farm-bar-cream);
  background: linear-gradient(105deg, #172e24f7, #203c30fb 60%, #192e26f7);
  border-bottom: 1px solid var(--farm-bar-line);
  box-shadow: 0 3px 15px #0a1a1633;
  font: 14px/1.3 'Segoe UI', Arial, sans-serif;
  pointer-events: auto;
}
.farm-bar {
  display: flex;
  align-items: center;
  min-height: var(--farm-bar-height);
  gap: clamp(13px, 2vw, 36px);
  padding: max(env(safe-area-inset-top), 0px) max(env(safe-area-inset-right), clamp(14px, 3vw, 60px)) 0 max(env(safe-area-inset-left), clamp(14px, 3vw, 60px));
  max-width: 1700px;
  margin-inline: auto;
}
.farm-bar-brand { display: flex; flex: none; align-items: center; gap: 8px; white-space: nowrap; }
.farm-bar-brand img { display: block; width: 42px; height: 42px; object-fit: contain; }
.farm-bar-brand strong {
  color: #edc07f;
  font: bold 21px/1.25 "Boiserie signature", "Preahvihear", sans-serif;
}
.farm-bar-place {
  border-inline-start: 1px solid var(--farm-bar-line);
  padding-inline-start: clamp(12px, 2vw, 31px);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.farm-bar-place > svg { flex: none; color: var(--farm-bar-gold); }
.farm-bar-place > div { min-width: 0; }
.farm-bar-place #location { display: block; font: 600 15px/1.25 Georgia, serif; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.farm-bar-place #exploration-progress { display: block; margin: 4px 0 0; color: #dadfcd; font-size: 11px; }
#farm-game-header #visit {
  position: static;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: none;
  margin: 0 0 0 auto;
  padding: 0;
  gap: 3px;
  max-width: none;
}
#farm-game-header #visit::before { content: none; }
#farm-game-header #visit button,
#farm-game-header #farm-tools-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  height: auto;
  min-height: 42px;
  margin: 0;
  padding: 8px clamp(7px, .78vw, 14px);
  color: var(--farm-bar-cream);
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  box-shadow: none;
  text-shadow: none;
  font: 600 13px/1.25 'Segoe UI', Arial, sans-serif;
  cursor: pointer;
  transform: none;
}
#farm-game-header #visit button svg,
#farm-game-header #farm-tools-toggle svg {
  display: block;
  flex: none;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#farm-game-header #visit button span { display: inline; }
#farm-game-header #visit #exit-world {
  border-color: #bda4789c;
  margin-inline-start: 8px;
  color: #ffefc9;
}
#farm-game-header #visit button:hover,
#farm-game-header #farm-tools-toggle:hover,
#farm-game-header button[aria-expanded="true"],
#farm-game-header #visit button[aria-pressed="true"] {
  background-color: #f3ead419;
  color: #fff9e8;
}
#farm-game-header button:focus-visible {
  outline: 2px solid #efc77b;
  outline-offset: 2px;
}
#farm-game-header #farm-tools-toggle { display: none; }
#foreground-controls #avatar-panel,
#foreground-controls #sound-panel {
  top: calc(74px + env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  overflow-y: auto;
  max-height: calc(100dvh - 88px - env(safe-area-inset-top));
}
body[data-farm-stage] .farm-visit { top: calc(78px + env(safe-area-inset-top)); }
@media (min-width: 981px) and (max-width: 1100px) {
  .farm-bar { gap: 15px; padding-inline: 15px; }
  .farm-bar-brand strong { font-size: 18px; }
  .farm-bar-place { gap: 6px; padding-inline-start: 14px; }
  #farm-game-header #visit button { padding-inline: 7px; gap: 5px; font-size: 12px; }
}
@media (max-width: 980px) {
  #farm-game-header { --farm-bar-height: 52px; }
  .farm-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .farm-bar-brand { min-height: var(--farm-bar-height); }
  .farm-bar-brand img { width: 34px; height: 34px; }
  .farm-bar-brand strong { font-size: clamp(16px, 3.8vw, 19px); }
  .farm-bar-place {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 30px;
    border: 0;
    border-top: 1px solid #c8aa7036;
    padding: 3px 0;
    gap: 6px;
  }
  .farm-bar-place > svg { width: 14px; height: 14px; }
  .farm-bar-place > div { display: flex; align-items: baseline; gap: 8px; flex: 1; }
  .farm-bar-place #location { font-size: 13px; }
  .farm-bar-place #exploration-progress { flex: none; margin: 0 0 0 auto; font-size: 10px; white-space: nowrap; }
  #farm-game-header #farm-tools-toggle {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
    min-height: 42px;
    border-color: #c8aa7066;
    padding: 5px 9px;
  }
  #farm-game-header #visit {
    position: absolute;
    z-index: 1;
    inset: auto max(8px, env(safe-area-inset-right)) auto auto;
    top: calc(100% + 5px) !important;
    right: max(8px, env(safe-area-inset-right)) !important;
    display: none;
    min-width: 180px;
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 94px - env(safe-area-inset-top));
    overflow-y: auto;
    padding: 5px;
    border: 1px solid #bdac83;
    border-radius: 8px;
    background: #203c30;
    box-shadow: 0 9px 20px #0e221c66;
  }
  #farm-game-header #visit.is-open { display: grid; grid-template-columns: 1fr; gap: 1px; justify-content: stretch; }
  #farm-game-header #visit button { justify-content: flex-start; min-height: 44px; padding-inline: 12px; }
  #farm-game-header #visit #exit-world { margin: 3px 0 0; border: 0; border-top: 1px solid #bda4785c; border-radius: 0; }
  #foreground-controls #avatar-panel, #foreground-controls #sound-panel {
    top: calc(88px + env(safe-area-inset-top)); max-height: calc(100dvh - 100px - env(safe-area-inset-top));
    width: min(330px, calc(100vw - 24px));
  }
  body[data-farm-stage] .farm-visit { top: calc(91px + env(safe-area-inset-top)) !important; }
  body[data-farm-stage] .farm-visit-content { max-height: calc(100dvh - 146px - env(safe-area-inset-top)); }
}
@media (max-height: 530px) {
  .farm-entry-shell #world-loader .world-loader-guide { display: none; }
  .farm-entry-shell #world-loader { padding: 10px 14px 12px; }
  .farm-entry-shell #world-loader .world-loader-card { margin: 0; padding: 6px; }
  .farm-entry-shell #world-loader #world-loader-enter { top: 32%; min-height: 57px; padding: 8px 20px; font-size: 21px; }
  .farm-entry-shell #world-loader #world-loader-enter .world-loader-tree { width: 27px; height: 35px; }
}
@media (max-height: 500px) and (max-width: 980px) {
  .farm-bar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; }
  .farm-bar-place {
    grid-column: 2; grid-row: 1; border: none; padding: 0;
    border-left: 1px solid var(--farm-bar-line); padding-left: 12px;
  }
  .farm-bar-place > div { display: block; }
  .farm-bar-place #exploration-progress { display: block; }
  #farm-game-header #farm-tools-toggle { grid-column: 3; }
  body[data-farm-stage] .farm-visit { top: calc(60px + env(safe-area-inset-top)) !important; }
  #foreground-controls #avatar-panel, #foreground-controls #sound-panel { top: calc(59px + env(safe-area-inset-top)); max-height: calc(100dvh - 68px); }
}
