/* The scene owns the sheet's footprint. Only the illustrated folio and its
   scrollable contents are styled here so camera space stays independent. */
#estate-detail {
  --folio-paper:#f7f1e3;
  --folio-ink:#20382e;
  --folio-secondary:#575c4f;
  --folio-rule:#d4c9af;
  --folio-gold:#96753f;
  --folio-gutter:clamp(13px,1.1vw,22px);
  background-color:var(--folio-paper);
  color:var(--folio-ink);
  border:1px solid #ab9467;
  border-radius:7px;
  box-shadow:0 9px 26px #18241e54,0 1px 5px #18241e42;
  padding:0;
}

@media(min-width:761px) and (min-height:501px){
  .estate-scene.has-estate-sheet {--panel-width:clamp(340px,26vw,400px)}
  .estate-scene #estate-detail {max-height:calc(100% - 144px)}
  #estate-detail .est-sheet-body {font-size:15px}
  #estate-detail .est-cost-lines dd em {font-size:13px;font-weight:650}
  /* Keep occupied and selected sites visible. The plot, focus target and locator
     remain available for every quiet parcel even when its caption is tucked away. */
  .estate-object:is(.empty,.landmark-plot):not(.keep-plot,.upgrading,.building,[aria-pressed=true],:focus-visible,:hover)+.est-caption {display:none}
  .estate-object.empty .est-survey {display:grid}
}
#estate-detail .est-sheet-head {
  position:relative;
  align-items:center;
  padding:8px 6px 8px var(--folio-gutter);
  border:0;border-bottom:2px solid #ab8c54;
  background:#213c32;color:#fff6e2;
  gap:5px;
}
.est-head-art {display:none}
#estate-detail .est-sheet-head>div {display:flex;align-items:baseline;flex-wrap:wrap;gap:3px 9px;min-width:0}
#est-sheet-title {
  margin:0;color:#fff8e4;overflow-wrap:anywhere;
  font:700 clamp(1.35rem,1.65vw,2rem)/1.32 var(--serif);
  letter-spacing:-.055em;
}
#estate-detail .est-state {display:inline-block;color:#e3d2a7;font-size:.78rem;font-weight:650}
#estate-detail .est-sheet-head button {
  color:#f6ead2;min-width:44px;min-height:44px;flex:none;
  background:transparent;border:0;border-radius:3px;
  margin:-3px 0 0;padding:0 4px;
}
#estate-detail .est-sheet-head button:hover {background:#3c5448}
#estate-detail .est-sheet-head [data-estate-expand] {display:inline-flex;align-items:center;justify-content:center;gap:2px;font-size:.8rem}
#estate-detail [data-estate-expand] .icon {width:.8rem;transform:rotate(90deg)}
#estate-detail [data-estate-expand][aria-expanded="true"] .icon {transform:rotate(-90deg)}
#estate-detail .est-close {width:44px}
#estate-detail .est-close .icon {width:22px;height:22px}
#estate-detail .est-sheet-body {padding:0 var(--folio-gutter) 9px;scrollbar-color:#b7a17b transparent}
.est-portrait {
  position:relative;overflow:hidden;display:grid;place-items:end center;
  margin:0 calc(-1 * var(--folio-gutter)) 10px;width:calc(100% + 2 * var(--folio-gutter));aspect-ratio:2.23;min-height:0;
  border:0;border-bottom:1px solid #b9a17b;border-radius:0;
  box-shadow:inset 0 0 0 1px #ffefd26b;background-color:#d9caa4;
}
.est-portrait-farm {background:#c9ba85 url('./assets/farm-landscape.webp') center/cover}
.est-portrait-atlas {background:#aeab7e url('./assets/estate-highlands.webp') 50% 42% / 130% auto}
.est-portrait-atlas::before {content:"";position:absolute;inset:0;background:linear-gradient(#f6eccb27,#d9d2a459 62%,#89825055)}
.est-portrait-atlas .est-thumb {position:absolute;bottom:5%;width:auto;height:88%;aspect-ratio:1;filter:drop-shadow(2px 3px 2px #3f34254d)}
.est-portrait-atlas img {position:absolute;bottom:2%;width:80%;height:95%;object-fit:contain;filter:drop-shadow(2px 3px 2px #3f34254d)}
.est-portrait figcaption {z-index:1;justify-self:start;margin:6px;padding:2px 6px;background:#25372b;color:#fff1cf;border-radius:2px;font-size:.75rem}
#estate-detail .est-level {margin:4px 0 8px;justify-content:flex-start}
#estate-detail .est-level strong {
  position:relative;display:inline-block;
  padding:3px 0;text-align:left;color:#294235;
  font:700 clamp(1.1rem,1.36vw,1.48rem)/1.2 var(--serif);
}
.est-level strong span {color:#79643c;margin-inline:2px}
#estate-detail .est-stat {color:var(--folio-ink);border:0}
#estate-detail .est-effect {display:block;padding:8px 0;border-bottom:1px solid var(--folio-rule)}
#estate-detail .est-effect-name,#estate-detail .est-expense h3,#estate-detail .est-clock>span {
  display:inline-flex;align-items:center;gap:7px;margin:0;
  color:#383f2d;font:600 .94rem/1.4 var(--sans);
}
#estate-detail .est-effect-name .icon,#estate-detail .est-clock .icon,#estate-detail .est-expense h3 .icon {color:#72582b;width:1.15em;height:1.15em}
.est-effect-values {display:flex;align-items:baseline;flex-wrap:wrap;gap:2px 6px;padding-left:1.5rem}
#estate-detail .est-effect-values strong,#estate-detail .est-clock strong {font:700 clamp(1.05rem,1.2vw,1.34rem)/1.38 var(--serif);color:#293b2c;font-variant-numeric:tabular-nums}
#estate-detail .est-effect-values .est-after {color:#3d5932}
#estate-detail .est-effect-values .est-arrow,#estate-detail .est-effect-values small {color:var(--folio-secondary);font-size:.82rem}
.est-expense {padding:9px 0 8px;border-bottom:1px solid var(--folio-rule)}
#estate-detail .est-cost-lines {
  margin:6px 0 0;display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(100%,max(7.75rem,calc(50% - 5px))),1fr));gap:6px 10px;
}
#estate-detail .est-cost-lines>div {display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:5px;align-items:baseline;justify-content:start}
#estate-detail .est-cost-lines dt {font-size:.89rem;color:#384936;white-space:nowrap}
#estate-detail .est-cost-lines dt .icon {color:#5c6849;align-self:center}
#estate-detail .est-cost-lines dd {display:contents;text-align:start}
#estate-detail .est-cost-lines dd b {font:700 1.04rem/1.2 var(--serif);color:#293b2c;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
#estate-detail .est-cost-lines dd span,#estate-detail .est-cost-lines dd em {grid-column:1/-1;font-size:.78rem;color:var(--folio-secondary);line-height:1.25}
#estate-detail .est-cost-lines dd em {color:#853c24}
.est-clock {display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:4px 9px;padding:9px 0 5px}
#estate-detail .est-job-time,#estate-detail .est-desc {color:#454d38;font-size:.9rem}
#estate-detail .est-blocker {color:#75421c;padding:3px 0;font-size:.875rem}
#estate-detail #est-extra {border-top:1px solid var(--folio-rule);padding-top:7px;margin-top:6px}
#estate-detail #est-extra .est-stat span {color:var(--folio-secondary)}
#estate-detail .est-sheet-actions {
  position:relative;flex:none;gap:6px;align-items:stretch;
  padding:9px var(--folio-gutter);border:0;border-top:1px solid var(--folio-rule);background:#eee6d5;
}
#estate-detail .est-sheet-actions button {
  min-height:46px;flex:1 1 85px;font:700 1rem/1.25 var(--serif);
  padding:7px 9px;overflow-wrap:anywhere;color:#453d29;background-color:#f0e0be;
  border:1px solid #b7a47c;border-radius:4px;box-shadow:inset 0 1px 0 #fbf2dc;
}
#estate-detail .est-sheet-actions button:first-of-type {
  flex-grow:1.45;color:#fff2d3;background-color:#234437;border-color:#335446;
  box-shadow:inset 0 1px 0 #67765a,0 1px 2px #59492838;
}
#estate-detail .est-sheet-actions button:hover:enabled {background-color:#ebd4a6}
#estate-detail .est-sheet-actions button:first-of-type:hover:enabled {background-color:#315641}
#estate-detail .est-sheet-actions .est-blocker {margin:0; flex:1 0 100%; font-weight:650; line-height:1.35}
#estate-detail .est-sheet-actions .est-blocker time {color:inherit; font-variant-numeric:tabular-nums}
#estate-detail .est-register button {color:#2c4133;border-bottom-color:var(--folio-rule)}
#estate-detail .est-register button:hover {background:#f0e0be}
#estate-detail .est-manager-controls {padding-inline:var(--folio-gutter);padding-bottom:10px;margin-bottom:5px;border-color:var(--folio-rule)}
#estate-detail .est-register small,#estate-detail .est-register b {color:var(--folio-secondary)}
@media (min-width:761px) and (max-height:820px) {
  #estate-detail .est-sheet-head {padding-top:6px;padding-bottom:3px}
  .est-portrait {aspect-ratio:2.65;margin-bottom:5px}
  #estate-detail .est-level {margin-block:3px}
  #estate-detail .est-effect,.est-expense {padding-block:5px}
  #estate-detail .est-sheet-actions {padding-block:6px 9px}
}
@media (max-width:760px), (orientation:landscape) and (max-height:500px) {
  #estate-detail {--folio-gutter:12px;border-radius:5px 5px 0 0}
  #estate-detail .est-sheet-head {align-items:center;padding:2px 4px 1px var(--folio-gutter)}
  #estate-detail .est-sheet-head button {margin:0}
  #est-sheet-title {font-size:1.18rem}
  #estate-detail .est-sheet-head small {font-size:.78rem}
  #estate-detail .est-sheet-body {padding:0 var(--folio-gutter) 4px}
  .est-portrait {display:none}
  .estate-expanded .est-portrait {display:grid;aspect-ratio:3.6;max-height:130px;margin-bottom:5px}
  #estate-detail .est-level {margin:3px 0 2px;justify-content:flex-start}
  #estate-detail .est-level strong {font-size:1rem;min-width:0;padding:3px 0}
  #estate-detail .est-effect {padding:3px 0;display:flex;justify-content:space-between;flex-wrap:wrap;gap:2px 7px}
  .est-effect-values {padding:0}
  #estate-detail .est-effect-name,#estate-detail .est-expense h3,#estate-detail .est-clock>span {font-size:.875rem}
  #estate-detail .est-effect-values strong,#estate-detail .est-clock strong {font-size:1.03rem}
  .est-expense {padding:4px 0}
  #estate-detail .est-cost-lines {gap:4px 10px;margin-top:3px}
  .est-clock {padding:4px 0}
  #estate-detail .est-sheet-actions {padding:3px var(--folio-gutter) 5px}
  #estate-detail .est-sheet-actions button {min-height:44px;font-size:.92rem}
}
@media (max-width:760px) and (orientation:portrait) {
  .estate-scene:not(.estate-expanded) .est-head-art {
    display:grid;place-items:center;width:39px;height:35px;flex:none;
    border:1px solid #beab7b;border-radius:3px;background:#e6dcc1;margin:4px 3px 4px 0;
  }
  .est-head-art img,.est-head-art .est-thumb {width:100%;height:100%;object-fit:contain}
  .estate-scene.has-estate-sheet .est-nameplate {padding:4px 8px;max-width:calc(100% - 14px)}
  .estate-scene.has-estate-sheet .est-nameplate>span {display:none}
  .estate-scene.has-estate-sheet .est-nameplate>div {display:flex;flex-wrap:wrap;align-items:baseline;gap:1px 7px}
}
/* With a larger browser font in a short landscape viewport, keep the
   cost breakdown and actions part of the same scrollable folio. */
@media (orientation:landscape) and (max-height:500px) {
  .estate-expanded #estate-detail:not(:has(.est-register)) {overflow-y:auto;overscroll-behavior:contain}
  .estate-expanded #estate-detail:not(:has(.est-register)) .est-sheet-body {flex:1 0 auto;overflow:visible}
  .estate-expanded #estate-detail:not(:has(.est-register)) .est-sheet-actions {max-height:none;overflow:visible}
}
