/* layout.css
   Global reset/base type, login screen, app shell, HUD, main container,
   drawer, overlay, and image viewer. Structural chrome shared by every page.
   Depends on: variables.css (uses --paper/--ink/--teal/etc custom properties). */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, .serif {
  font-family: 'DM Serif Display', serif;
  font-weight: 400;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* LOGIN SCREEN */

#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
}

#loginScreen::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, var(--teal-l) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 30%, var(--amber-l) 0%, transparent 50%);
  opacity: .6;
  pointer-events: none;
}

.login-box {
  position: relative;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 400px;
  max-width: 92vw;
  overflow: hidden;
  animation: fadeUp .5s ease;
}

.login-header {
  padding: 32px 32px 24px;
  text-align: center;
  border-bottom: 1px solid var(--paper2);
}
.login-header h1 { font-size: 28px; margin-bottom: 4px; }
.login-header p { font-size: 13px; color: var(--ink3); }

.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--paper3);
}

.login-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink3);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  transition: all .2s;
}
.login-tab.active { color: var(--teal); border-bottom-color: var(--teal); }

.login-form { padding: 28px 32px 32px; }
.login-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--paper3);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  margin-bottom: 16px;
  outline: none;
}
.login-form input:focus { border-color: var(--teal); background: #fff; }
.login-form .hint {
  font-size: 11px;
  color: var(--ink4);
  margin-top: -12px;
  margin-bottom: 16px;
}
.login-error {
  color: var(--coral);
  font-size: 12px;
  margin-bottom: 12px;
  display: none;
}

/* APP SHELL / HUD */

#appShell { display: none; min-height: 100vh; }

.hud {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--paper3);
  box-shadow: 0 1px 4px rgba(26, 23, 20, .04);
}

.hud-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  color: var(--ink);
  flex-shrink: 0;
}
.hud-logo span { color: var(--teal); }

.hud-tabs {
  display: flex;
  gap: 4px;
  margin: 0 auto;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.hud-tabs::-webkit-scrollbar { display: none; }

.hud-tab {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink3);
  border-radius: 20px;
  cursor: pointer;
  border: none;
  background: none;
  position: relative;
  transition: all .2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.hud-tab:hover { color: var(--ink); background: var(--paper2); }
.hud-tab.active { color: var(--teal); background: var(--teal-l); font-weight: 600; }
.hud-tab .badge {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
}

.hud-user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.hud-user .username { font-size: 13px; font-weight: 500; color: var(--ink2); }
.hud-user .logout-btn {
  font-size: 12px;
  color: var(--ink4);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 4px;
}
.hud-user .logout-btn:hover { color: var(--coral); background: var(--coral-l); }

.main { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 24px; }

body.student-mode .instructor-only { display: none !important; }

/* DRAWER */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 20, .3);
  z-index: 180;
  opacity: 0;
  transition: opacity .25s;
  display: none;
}
.drawer-overlay.open { display: block; opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  right: -520px;
  width: 500px;
  max-width: 92vw;
  height: 100vh;
  background: #fff;
  z-index: 185;
  box-shadow: -4px 0 24px rgba(26, 23, 20, .1);
  transition: right .3s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.drawer.open { right: 0; }

.drawer-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--paper2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.drawer-head h3 { font-size: 18px; }

.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--paper2);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink3);
}
.drawer-close:hover { background: var(--paper3); color: var(--ink); }

.drawer-body { padding: 24px; flex: 1; overflow-y: auto; }

/* OVERLAY / MODAL */

.overlay-bg {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 20, .4);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}
.overlay-bg.open { display: flex; }

.overlay-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 500px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  animation: fadeUp .25s ease;
}

.overlay-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--paper2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.overlay-head h3 { font-size: 18px; }
.overlay-body { padding: 24px; }

/* IMAGE VIEWER */

.img-viewer {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, .92);
  z-index: 190;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.img-viewer.open { display: flex; }
.img-viewer img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  object-fit: contain;
}

.img-viewer-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .95);
  border-radius: 12px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 195;
}
.img-viewer-bar .btn { padding: 6px 12px; font-size: 12px; }

.img-viewer-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  border: none;
  font-size: 20px;
  cursor: pointer;
  z-index: 196;
  display: flex;
  align-items: center;
  justify-content: center;
}
