/* ═════════════════════════════════════════════════════════════════════════════
   AETERIA TABLET STUDIO — tablet-improvements.css
   50 UI / UX & Performance Enhancements (Atelier Obsidian v3.1 Specification)
   ═════════════════════════════════════════════════════════════════════════════ */

/* ── PART 1: VISUALS & AESTHETICS (T1–T15) ────────────────────────────────── */

/* T1: Dynamic Smoked Glass Depth on Tablet Frame */
.tablet {
  position: relative;
  background:
    radial-gradient(120% 150% at 85% -10%, rgba(232, 100, 26, 0.07), transparent 48%),
    radial-gradient(90% 120% at 15% 110%, rgba(255, 255, 255, 0.02), transparent 45%),
    linear-gradient(168deg, rgba(28, 28, 33, 0.95), rgba(14, 14, 17, 0.98) 58%, rgba(8, 8, 10, 0.99)) !important;
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  box-shadow:
    0 110px 180px -55px rgba(0, 0, 0, 0.94),
    0 45px 95px -40px rgba(0, 0, 0, 0.85),
    0 18px 40px -20px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.11),
    inset 0 -1px 0 rgba(0, 0, 0, 0.7) !important;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
  contain: layout style;
}

/* T2: Realistic Light Leak Caustics */
.tablet::before {
  content: "";
  position: absolute;
  top: 0; right: 46px;
  width: 280px; height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(232, 100, 26, 0.6) 30%, rgba(255, 170, 100, 0.85) 60%, transparent) !important;
  pointer-events: none;
  animation: leak-shimmer 7s ease-in-out infinite alternate;
}
@keyframes leak-shimmer {
  0% { opacity: 0.7; transform: scaleX(0.92); }
  100% { opacity: 1; transform: scaleX(1.06); }
}

.tablet::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 380px; height: 240px;
  border-radius: 0 var(--radius-slab) 0 90%;
  background: radial-gradient(115% 105% at 100% 0%, rgba(232, 100, 26, 0.16), rgba(232, 100, 26, 0.05) 45%, transparent 75%) !important;
  filter: blur(8px);
  pointer-events: none;
}

/* T3: Tactile Bezel Inset Highlights on Tablet Screen */
.tablet-screen {
  border-radius: calc(var(--radius-slab) - 8px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.8),
    inset 1px 0 0 rgba(255, 255, 255, 0.03),
    inset -1px 0 0 rgba(0, 0, 0, 0.4);
}

/* T4: Sleek OS Status Bar Indicator */
.os-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  color: var(--text-tertiary, rgba(255, 255, 255, 0.5));
  border-bottom: 1px solid var(--hairline, rgba(255, 255, 255, 0.06));
  background: rgba(12, 12, 15, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  user-select: none;
}
.os-statusbar .status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent, #E8641A);
  box-shadow: 0 0 8px var(--accent, #E8641A);
  animation: status-pulse 3s ease-in-out infinite;
}
@keyframes status-pulse {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

/* T5: Obsidian App Tile Glow on Home Screen */
.home-app-card, .os-home-tile {
  position: relative;
  border-radius: 14px;
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.08));
  background: linear-gradient(145deg, rgba(25, 25, 30, 0.8), rgba(12, 12, 15, 0.95));
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 18px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.home-app-card:hover, .os-home-tile:hover {
  transform: translateY(-3px) scale(1.015);
  border-color: rgba(232, 100, 26, 0.45);
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.85), 0 0 20px -4px rgba(232, 100, 26, 0.25);
}
.home-app-card::after, .os-home-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(232, 100, 26, 0.12), transparent 60%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.home-app-card:hover::after, .os-home-tile:hover::after {
  opacity: 1;
}

/* T6: Polished Navigation Rail */
.rail {
  background: rgba(14, 14, 18, 0.85) !important;
  border-right: 1px solid var(--hairline, rgba(255, 255, 255, 0.07)) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 12px 6px;
  gap: 6px;
}
.rail-btn {
  position: relative;
  border-radius: 10px;
  padding: 10px 8px;
  transition: all 0.18s ease;
  color: var(--text-tertiary, rgba(255, 255, 255, 0.48));
}
.rail-btn:hover {
  color: var(--text-primary, #ffffff);
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(2px);
}
.rail-btn.active {
  color: var(--accent-bright, #ff8c42) !important;
  background: rgba(232, 100, 26, 0.12) !important;
  box-shadow: inset 0 0 0 1px rgba(232, 100, 26, 0.35), 0 4px 14px -3px rgba(232, 100, 26, 0.3) !important;
}
.rail-btn.active::before {
  content: "";
  position: absolute;
  left: 0; top: 18%; bottom: 18%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent, #E8641A);
  box-shadow: 0 0 8px var(--accent, #E8641A);
}

/* T7: Subtab Counter Badges */
.db-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary, rgba(255, 255, 255, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}
.db-tab-btn.active .db-tab-badge {
  background: rgba(232, 100, 26, 0.25);
  color: var(--accent-bright, #ff8c42);
  border-color: rgba(232, 100, 26, 0.5);
  box-shadow: 0 0 8px rgba(232, 100, 26, 0.3);
}

/* T8: Cinematic Panel Transitions */
.panel {
  animation: panel-enter 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
  will-change: transform, opacity;
}
@keyframes panel-enter {
  0% { opacity: 0; transform: translateY(8px) scale(0.995); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* T9: Dynamic Ambient Time Ground */
[data-day-part="night"] .tablet {
  box-shadow: 0 110px 180px -55px rgba(0, 0, 0, 0.98), 0 0 60px -20px rgba(12, 18, 30, 0.4) !important;
}
[data-day-part="morning"] .tablet {
  box-shadow: 0 100px 170px -55px rgba(0, 0, 0, 0.92), 0 0 60px -20px rgba(232, 120, 40, 0.1) !important;
}

/* T10: Memory Card Chrono Tags */
.memory-item .chrono-tag, .mem-tag {
  display: inline-block;
  font-size: 9.5px;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary, rgba(255, 255, 255, 0.45));
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

/* T11: Dream Gallery Vignettes */
.dream-card, .dream-art-frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.08));
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.7);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.24s ease;
}
.dream-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(232, 100, 26, 0.4);
  box-shadow: 0 20px 44px -10px rgba(0, 0, 0, 0.85), 0 0 24px -6px rgba(232, 100, 26, 0.3);
}

/* T12: Instrument Gauge Shimmer */
.inst-gauge svg circle.gauge-val {
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.16, 1, 0.3, 1), stroke 0.3s ease;
  filter: drop-shadow(0 0 6px var(--accent, #E8641A));
}

/* T13: Bernard Chat Bubble Polish */
.bernard-msg {
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.07));
  margin-bottom: 10px;
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.5);
}
.bernard-msg.agent {
  border-left: 2px solid var(--accent, #E8641A);
  background: linear-gradient(90deg, rgba(232, 100, 26, 0.06), rgba(255, 255, 255, 0.02) 60%);
}

/* T14: Lineage Tree Node Pulses */
.lineage-node {
  transition: all 0.2s ease;
  cursor: pointer;
}
.lineage-node:hover circle {
  filter: drop-shadow(0 0 10px var(--accent, #E8641A));
  stroke: var(--accent-bright, #ff8c42);
  stroke-width: 2.5px;
}

/* T15: Sleek Precision Range Slider */
input[type="range"].tablet-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  transition: background 0.2s ease;
}
input[type="range"].tablet-slider:hover {
  background: rgba(255, 255, 255, 0.2);
}
input[type="range"].tablet-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent, #E8641A);
  box-shadow: 0 0 8px var(--accent, #E8641A);
  cursor: pointer;
  transition: transform 0.15s ease;
}
input[type="range"].tablet-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

/* ── PART 2: INTERACTIONS & MICRO-GESTURES (T16–T30) ──────────────────────── */

/* T17: 3D Perspective Tile Container */
.os-home-grid {
  perspective: 1200px;
}

/* T19: Subtab List Horizontal Scroll Feel */
.db-subnav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 10px;
}
.db-subnav::-webkit-scrollbar {
  display: none;
}

/* T21: Overscroll Pull Indicator */
.pull-refresh-cue {
  height: 0;
  overflow: hidden;
  text-align: center;
  color: var(--accent, #E8641A);
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  transition: height 0.2s ease, opacity 0.2s ease;
}

/* T24: Click-to-Copy Feedback Tooltip */
.copy-pill {
  cursor: pointer;
  position: relative;
}
.copy-pill:active {
  transform: scale(0.95);
}

/* T25: Audio Visualizer Bars */
.audio-viz-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.audio-viz-bar {
  width: 2px;
  background: var(--accent, #E8641A);
  border-radius: 1px;
  animation: viz-bounce 0.8s ease-in-out infinite alternate;
}
.audio-viz-bar:nth-child(2) { animation-delay: 0.2s; }
.audio-viz-bar:nth-child(3) { animation-delay: 0.4s; }
@keyframes viz-bounce {
  0% { height: 3px; }
  100% { height: 12px; }
}

/* T26: Dream Lightbox Modal */
.dream-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(8, 8, 10, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.dream-lightbox.open {
  opacity: 1;
  pointer-events: auto;
}
.dream-lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 16px;
  box-shadow: 0 30px 90px -20px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255, 255, 255, 0.1);
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.dream-lightbox.open img {
  transform: scale(1);
}

/* T28: Journal Reflection Accordion */
.journal-entry-body {
  max-height: 80px;
  overflow: hidden;
  position: relative;
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.journal-entry-body.expanded {
  max-height: 600px;
}
.journal-entry-body:not(.expanded)::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 35px;
  background: linear-gradient(to bottom, transparent, rgba(16, 16, 20, 0.95));
  pointer-events: none;
}

/* T29: Tactile Button Press Physics */
.tablet button:active, .os-home-tile:active {
  transform: scale(0.97) !important;
}

/* ── PART 3: STATE & DATA MANAGEMENT (T31–T40) ────────────────────────────── */

/* T34: Offline Network Alert Banner */
.tablet-offline-banner {
  display: none;
  background: rgba(232, 100, 26, 0.15);
  border: 1px solid rgba(232, 100, 26, 0.4);
  color: #ff9a4d;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  padding: 6px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  align-items: center;
  gap: 8px;
}
.tablet-offline-banner.visible {
  display: flex;
}

/* T38: Real-time Notification Badge */
.tile-unread-badge {
  position: absolute;
  top: 10px; right: 10px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent, #E8641A);
  box-shadow: 0 0 10px var(--accent, #E8641A);
}

/* T39: Action Undo Toast */
.tablet-undo-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  background: rgba(20, 20, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8);
  transform: translateY(60px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.tablet-undo-toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.tablet-undo-btn {
  background: none;
  border: none;
  color: var(--accent-bright, #ff8c42);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

/* ── PART 4: PERFORMANCE & OPTIMIZATION (T41–T50) ─────────────────────────── */

/* T41: CSS contain: content Isolation */
.panel, .tablet-screen, .os-home {
  contain: content;
}

/* T42: content-visibility on Inactive Panels */
.panel[hidden] {
  content-visibility: hidden;
  display: none !important;
}

/* T43: Hardware-Accelerated Transforms */
.tablet, .rail-btn, .home-app-card, .dream-card {
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

/* T47: Smooth Monospace Rendering */
.os-statusbar, .chrono-tag, .db-tab-badge {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* T50: Prefers Reduced Motion Strict Fallback */
@media (prefers-reduced-motion: reduce) {
  .tablet, .panel, .rail-btn, .home-app-card, .dream-card, .audio-viz-bar, .tablet::before {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}
