/* v1.8.4 Phase 3 — Modern Control System.
   Presentation-only contract for Origines controls. Geometry, gameplay and rail
   structure remain owned by their existing layers. */
:root{
  --ag-modern-control-surface:rgba(17,23,32,.74);
  --ag-modern-control-hover:rgba(25,33,44,.9);
  --ag-modern-control-pressed:rgba(10,14,20,.84);
  --ag-modern-control-border:rgba(237,224,199,.14);
  --ag-modern-control-border-hover:rgba(229,196,119,.42);
  --ag-modern-control-shadow:inset 0 1px 0 rgba(255,255,255,.035),0 5px 15px rgba(0,0,0,.14);
  --ag-modern-control-shadow-hover:inset 0 1px 0 rgba(255,255,255,.055),0 8px 20px rgba(0,0,0,.2);
  --ag-modern-control-selected:rgba(181,138,77,.13);
  --ag-modern-control-selected-border:rgba(209,173,104,.5);
  --ag-modern-control-font-size:.79rem;
  --ag-modern-control-height:36px;
}

[data-game-architecture="v1"] .ag-button[data-control-role]{
  min-height:var(--ag-modern-control-height);
  border-radius:10px;
  border-color:var(--ag-modern-control-border);
  background:var(--ag-modern-control-surface);
  color:var(--ag-text-primary);
  box-shadow:var(--ag-modern-control-shadow);
  font-size:var(--ag-modern-control-font-size);
  font-weight:650;
  letter-spacing:.004em;
  line-height:1;
}
[data-game-architecture="v1"] .ag-button[data-control-role="primary"]{
  border-color:rgba(209,173,104,.56);
  background:linear-gradient(180deg,#c29a58,#9a6f39);
  color:var(--ag-text-on-accent);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.14),0 8px 22px rgba(181,138,77,.17);
  font-weight:780;
}
[data-game-architecture="v1"] .ag-button[data-control-role="secondary"]{
  border-color:var(--ag-modern-control-border);
  background:var(--ag-modern-control-surface);
  color:var(--ag-text-primary);
}
[data-game-architecture="v1"] .ag-button[data-control-role="toggle"]{
  border-color:var(--ag-modern-control-border);
  background:rgba(13,18,25,.7);
  color:var(--ag-text-secondary);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.025);
}
[data-game-architecture="v1"] .ag-button[data-control-role="toggle"][aria-pressed="true"]{
  border-color:var(--ag-modern-control-selected-border);
  background:var(--ag-modern-control-selected);
  color:var(--ag-text-primary);
  box-shadow:inset 0 0 0 1px rgba(209,173,104,.08),0 5px 16px rgba(0,0,0,.12);
}
[data-game-architecture="v1"] .ag-button[data-control-role="contextual"]{
  border-color:rgba(209,173,104,.28);
  background:rgba(181,138,77,.075);
  color:var(--ag-text-contextual);
}
[data-game-architecture="v1"] .ag-button[data-control-role="danger"]{
  border-color:rgba(208,111,103,.3);
  background:rgba(208,111,103,.075);
  color:var(--ag-text-danger);
}

@media(hover:hover){
  [data-game-architecture="v1"] .ag-button[data-control-role]:not(:disabled):not([aria-disabled="true"]):hover{
    border-color:var(--ag-modern-control-border-hover);
    background:var(--ag-modern-control-hover);
    box-shadow:var(--ag-modern-control-shadow-hover);
    transform:translateY(-1px);
  }
  [data-game-architecture="v1"] .ag-button[data-control-role="primary"]:not(:disabled):hover{
    border-color:rgba(229,196,119,.68);
    background:linear-gradient(180deg,#d0aa66,#aa7a3e);
  }
}
[data-game-architecture="v1"] .ag-button[data-control-role]:not(:disabled):active{
  transform:translateY(0);
  background:var(--ag-modern-control-pressed);
  box-shadow:inset 0 1px 2px rgba(0,0,0,.3);
}
[data-game-architecture="v1"] .ag-button[data-control-role]:focus-visible,
[data-game-architecture="v1"] :is(select,input)[data-control-field]:focus-visible{
  outline:2px solid var(--ag-focus);
  outline-offset:2px;
  box-shadow:0 0 0 4px rgba(229,196,119,.1),var(--ag-modern-control-shadow);
}
[data-game-architecture="v1"] .ag-button[data-control-role]:disabled,
[data-game-architecture="v1"] .ag-button[data-control-role][aria-disabled="true"]{
  opacity:.42;
  border-color:rgba(237,224,199,.09);
  background:rgba(255,255,255,.018);
  box-shadow:none;
  transform:none;
  filter:saturate(.62);
}

/* Header/navigation controls share one compact desktop rhythm across all families. */
:is(.traditional-head-actions,.tool-actions){gap:.34rem}
:is(.traditional-head-actions,.tool-actions) .ag-button[data-control-role]{
  height:var(--ag-modern-control-height);
  min-height:var(--ag-modern-control-height);
  padding:0 .7rem;
  white-space:nowrap;
}
:is(.traditional-head-actions,.tool-actions) .ag-button[data-control-icon]::before,
.ag-variant-collapse-toggle[data-control-icon]::before{
  width:.95rem;
  height:.95rem;
  flex-basis:.95rem;
  background:var(--ag-control-tone,var(--ag-text-subtle));
  opacity:.88;
}
:is(.traditional-head-actions,.tool-actions) .ag-button[data-control-icon][aria-pressed="true"]::before,
.ag-variant-collapse-toggle[aria-expanded="true"]::before{opacity:1}
:is(.traditional-head-actions,.tool-actions) .ag-button[aria-pressed="true"]{
  border-color:rgba(var(--ag-control-tone-rgb,209,173,104),.48);
  background:rgba(var(--ag-control-tone-rgb,209,173,104),.11);
  color:var(--ag-text-primary);
}

/* Variant selector is a real toggle, not an anonymous secondary button. */
.ag-variant-collapse-toggle[aria-expanded="true"]{
  border-color:rgba(169,149,215,.48)!important;
  background:rgba(169,149,215,.105)!important;
  color:var(--ag-text-primary)!important;
  box-shadow:inset 0 0 0 1px rgba(169,149,215,.06),0 5px 16px rgba(0,0,0,.12)!important;
}
.ag-variant-collapse-toggle[aria-expanded="false"]{
  border-color:var(--ag-modern-control-border)!important;
  background:var(--ag-modern-control-surface)!important;
  color:var(--ag-text-subtle)!important;
  box-shadow:var(--ag-modern-control-shadow)!important;
}

/* Fields now belong to the same control family while retaining native semantics. */
[data-game-architecture="v1"] :is(select,input)[data-control-field]{
  min-height:var(--ag-modern-control-height);
  border:1px solid var(--ag-modern-control-border);
  border-radius:10px;
  background:rgba(7,11,16,.82);
  color:var(--ag-text-primary);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.025);
}
[data-game-architecture="v1"] :is(select,input)[data-control-field]:disabled{
  opacity:.5;
  background:rgba(255,255,255,.018);
}

@media(max-width:899px){
  [data-game-architecture="v1"] .ag-button[data-control-role],
  [data-game-architecture="v1"] :is(select,input)[data-control-field]{min-height:40px}
  :is(.traditional-head-actions,.tool-actions) .ag-button[data-control-role]{height:auto;min-height:40px}
}

@media(prefers-reduced-motion:reduce){
  [data-game-architecture="v1"] .ag-button[data-control-role]{transform:none!important}
}
