/* layout.css — app shell, screens, panels, header/menu, offline bar */

:root{
  --pane-side-margin: 40px;
  --pane-max-width: 680px;
}

*{ box-sizing: border-box; margin: 0; padding: 0; }

html, body{
  height: 100%;
  touch-action: manipulation;
}

body{
  background: #1a1008;
  color: #e8d5a3;
  font-family: 'EB Garamond', Georgia, serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Floating header */
header{
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100vw - (var(--pane-side-margin) * 2));
  max-width: var(--pane-max-width);

  background: rgba(13, 8, 3, 0.82);
  border: 1px solid #5a3a10;
  border-radius: 14px;
  padding: 10px 12px;

  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;

  z-index: 60;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}

/* Add top space so content isn't hidden under the floating header */
#app{
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
  padding-top: 86px;
}

.header-title{ text-align: center; flex: 1; min-width: 0; }
.header-title h1{
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  color: #c9a227;
  letter-spacing: 1.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-title p{ display:none; }
.header-title .header-line{ display:block; line-height: 1.05; }

/* Hamburger + menu */
.header-left{ width: 44px; display:flex; justify-content:flex-start; }
.header-spacer{ width: 44px; flex: 0 0 auto; }

.hamburger{
  width: 44px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #5a3a10;
  background: rgba(46,27,8,0.65);
  color: #e8d5a3;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.hamburger:hover{ border-color: #c9a227; color: #c9a227; }

.header-user{ display:none; } /* replaced by hamburger menu */

.header-menu{
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100vw - (var(--pane-side-margin) * 2));
  max-width: var(--pane-max-width);

  background: rgba(35, 21, 8, 0.96);
  border: 1px solid #5a3a10;
  border-radius: 14px;
  padding: 12px;
  z-index: 70;

  display: none;
  box-shadow: 0 18px 46px rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-menu.open{ display: block; }

.header-menu .username{
  color: #c9a227;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.header-menu a{
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: #e8d5a3;
  border: 1px solid #3a2010;
  background: rgba(46,27,8,0.55);
  margin-top: 8px;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  letter-spacing: 0.4px;
}

.header-menu a:hover{ border-color:#c9a227; color:#c9a227; }

.menu-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 65;
  display: none;
}
.menu-overlay.open{ display:block; }

/* Offline warning bar */
.offline-bar{
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100vw - (var(--pane-side-margin) * 2));
  max-width: var(--pane-max-width);
  z-index: 80;

  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;

  background: rgba(160, 48, 32, 0.92);
  border: 1px solid rgba(240, 128, 96, 0.65);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  color: #ffe7de;
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.4px;
}

.offline-bar.visible{ display:flex; }

.offline-bar .offline-dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ffd2c6;
  box-shadow: 0 0 0 2px rgba(26,16,8,0.5);
  flex: 0 0 auto;
}

.offline-bar .offline-text{ flex: 1; min-width: 0; }

.offline-bar .offline-btn{
  border: 1px solid rgba(255, 231, 222, 0.45);
  background: rgba(26,16,8,0.35);
  color: #ffe7de;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.74rem;
}

.offline-bar .offline-btn:hover{ border-color: #ffe7de; }

/* Screens */
.screen{
  display: none;
  width: 100%;
  max-width: 680px;
  padding: 24px 20px;
}

.screen.active{
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Panels */
.panel{ background: #231508; border: 1px solid #5a3a10; border-radius: 10px; padding: 22px; }
.panel h2{ font-family: 'Cinzel', serif; color: #c9a227; font-size: 1rem; margin-bottom: 14px; border-bottom: 1px solid #5a3a10; padding-bottom: 10px; letter-spacing: 1px; }

/* Complete screen */
.complete-actions{
  margin-top: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Ritual chooser tree */
.order-group{ margin-bottom: 8px; }
.order-header{ display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; border-radius: 8px; transition: background 0.2s; user-select: none; }
.order-header:hover{ background: #2e1b08; }
.order-icon{ font-size: 1.2rem; }
.order-name{ font-family: 'Cinzel', serif; font-size: 0.9rem; color: #c9a227; flex: 1; letter-spacing: 0.5px; }
.order-chevron{ color: #a08060; transition: transform 0.2s; font-size: 0.9rem; }
.order-group.open .order-chevron{ transform: rotate(90deg); }
.order-rituals{ display: none; flex-direction: column; gap: 8px; padding: 4px 0 8px 20px; }
.order-group.open .order-rituals{ display: flex; }

/* Ceremony groups (within an Order) */
.ceremony-group{ margin: 4px 0 10px 0; }
.ceremony-header{ display:flex; align-items:center; gap:10px; padding: 10px 12px; cursor:pointer; user-select:none; border-radius: 8px; background: rgba(46,27,8,0.35); border: 1px solid #3a2010; }
.ceremony-header:hover{ border-color:#c9a227; }
.ceremony-name{ font-family:'Cinzel',serif; font-size: 0.82rem; color:#e8d5a3; flex:1; letter-spacing: 0.4px; }
.ceremony-chevron{ color:#a08060; transition: transform 0.2s; font-size:0.9rem; }
.ceremony-group.open .ceremony-chevron{ transform: rotate(90deg); }
.ceremony-items{ display:none; flex-direction:column; gap:8px; padding: 10px 0 4px 14px; }
.ceremony-group.open .ceremony-items{ display:flex; }

/* Ritual cards (leaf nodes) */
.ritual-card{ background: #2e1b08; border: 1px solid #5a3a10; border-radius: 8px; padding: 13px 16px; cursor: pointer; transition: all 0.2s; display: flex; justify-content: space-between; align-items: center; }
.ritual-card:hover{ border-color: #c9a227; background: #3a2210; }
.ritual-card .ritual-title{ font-size: 0.95rem; color: #e8d5a3; }
.ritual-card .ritual-arrow{ color: #c9a227; }
.ritual-card.loading{ opacity: 0.5; cursor: wait; }

/* Role grid */
#screen-roles{ padding-bottom: 190px; }
.role-grid{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-btn{ background: #2e1b08; border: 2px solid #5a3a10; border-radius: 8px; color: #e8d5a3; font-family: 'Cinzel', serif; font-size: 0.82rem; padding: 14px 10px; cursor: pointer; transition: all 0.2s; text-align: center; }
.role-btn:hover{ border-color: #c9a227; color: #c9a227; background: #3a2210; }
.role-btn.selected{ border-color: #c9a227; background: #4a2c0a; color: #f0d060; }
.role-btn .role-abbr{ font-size: 1.2rem; font-weight: 700; display: block; margin-bottom: 4px; }
.role-btn .role-name{ font-size: 0.68rem; opacity: 0.8; }

/* Role screen: floating bottom actions */
.role-actions-float{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  width: calc(100vw - (var(--pane-side-margin) * 2));
  max-width: var(--pane-max-width);

  background: rgba(26,16,8,0.92);
  border: 1px solid #5a3a10;
  border-radius: 14px;
  padding: 12px;
  z-index: 40;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);

  display: none;
  gap: 10px;
  flex-direction: column;
}

#screen-roles.active ~ .role-actions-float{ display: flex; }

/* Ensure both buttons look like buttons (not browser-default) */
.role-actions-float .start-btn,
.role-actions-float .nav-btn{
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.1;
}

.role-actions-float .nav-btn{
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #5a3a10;
  background: rgba(46,27,8,0.55);
  color: #e8d5a3;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.4px;
  cursor: pointer;
}

.role-actions-float .nav-btn:hover{
  border-color: #c9a227;
  color: #c9a227;
}

/* Buttons (shared) */
.start-btn{ width: 100%; padding: 16px; background: linear-gradient(135deg, #c9a227, #a07820); border: none; border-radius: 8px; color: #1a1008; font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 700; cursor: pointer; letter-spacing: 1px; transition: opacity 0.2s; }
.start-btn:disabled{ opacity: 0.35; cursor: not-allowed; }
.start-btn:not(:disabled):hover{ opacity: 0.85; }

.ctrl-btn{ flex: 1; min-width: 90px; padding: 13px 8px; border-radius: 8px; border: 2px solid #5a3a10; background: #2e1b08; color: #e8d5a3; font-family: 'Cinzel', serif; font-size: 0.78rem; cursor: pointer; transition: all 0.2s; text-align: center; }
.ctrl-btn:hover:not(:disabled){ border-color: #c9a227; color: #c9a227; }
.ctrl-btn:disabled{ opacity: 0.35; cursor: not-allowed; }
.ctrl-btn.primary{ background: #c9a227; color: #1a1008; border-color: #c9a227; font-weight: 700; }
.ctrl-btn.primary:hover:not(:disabled){ background: #a07820; border-color: #a07820; }
.ctrl-btn.danger{ border-color: #a03020; color: #f08060; }
.ctrl-btn.danger:hover:not(:disabled){ background: #3a1a10; }

@media (max-width: 420px){
  :root{ --pane-side-margin: 14px; }
  .screen{ padding: 20px 14px; }
  header{ top: 10px; }
}
