/* ==========================================================================
   Retro PDA Simulator Stylesheet (index.css)
   ========================================================================== */

/* 引入复古等宽像素字体，以及现代 Montserrat 字体作为 dashboard 使用 */
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&family=Outfit:wght@300;400;600;700&display=swap');

:root {
  --font-pda: 'Courier Prime', monospace;
  --font-dash: 'Outfit', sans-serif;

  /* 塑料外壳配色：复古商务灰 */
  --pda-shell-bg: #8c8f8b;
  --pda-shell-highlight: #b8bcb9;
  --pda-shell-shadow: #5a5d59;
  --pda-shell-dark: #323531;

  /* 墨绿液晶屏色彩 (Gameboy/Palm Pilot 风格) */
  --lcd-bg-off: #8bad0f;
  --lcd-bg-on: #9bbc0f;
  --lcd-backlight: #a3ffd6; /* 偏振冷绿背光 */
  --lcd-ink: #0f380f;
  --lcd-ink-dim: #306230;

  /* 页面背景 */
  --page-bg: #1e201e;
  --dashboard-bg: #2d302e;
  --text-color: #e3e7e4;
}

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

body {
  background-color: var(--page-bg);
  color: var(--text-color);
  font-family: var(--font-dash);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  padding: 20px;
}

#app-container {
  display: flex;
  flex-direction: row;
  gap: 40px;
  max-width: 1000px;
  width: 100%;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* ==========================================================================
   1. PDA 物理机身 (拟物 Neumorphism 设计)
   ========================================================================== */
#pda-device {
  width: 320px;
  height: 520px;
  background-color: var(--pda-shell-bg);
  border-radius: 24px;
  padding: 16px 20px 20px 20px;
  position: relative;

  /* 拟物化外壳边缘立体阴影 */
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.55),
    0 6px 12px rgba(0, 0, 0, 0.25),
    inset 0 5px 8px var(--pda-shell-highlight),
    inset 0 -8px 14px var(--pda-shell-shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);

  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  border: 1px solid var(--pda-shell-shadow);

  /* 磨砂塑料颗粒纹理 */
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.08) 0px, rgba(255, 255, 255, 0) 1.5px),
    radial-gradient(circle at 70% 60%, rgba(0, 0, 0, 0.06) 0px, rgba(0, 0, 0, 0) 1.5px),
    radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.06) 0px, rgba(255, 255, 255, 0) 1.5px),
    radial-gradient(circle at 85% 15%, rgba(0, 0, 0, 0.05) 0px, rgba(0, 0, 0, 0) 1.5px);
  background-size: 120px 120px, 140px 140px, 100px 100px, 160px 160px;
}

/* 顶部红外窗口与指示灯 */
#pda-top-bar {
  width: 100%;
  height: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

#pda-ir-window {
  width: 50px;
  height: 6px;
  background-color: #2b0000;
  border-radius: 3px;
  margin: 0 auto;
  box-shadow: inset 0 1px 2px black;
}

#pda-power-indicator {
  width: 6px;
  height: 6px;
  background-color: #440000;
  border-radius: 50%;
  box-shadow: inset 0 1px 1px black;
  transition: background-color 0.3s;
}

#pda-power-indicator.power-on {
  background-color: #ff3300;
  box-shadow: 0 0 6px #ff3300, inset 0 1px 1px #ff9999;
}

/* 扬声器格栅 */
#pda-speaker {
  width: 80px;
  height: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-bottom: 12px;
}

.grill-line {
  width: 100%;
  height: 2px;
  background-color: var(--pda-shell-dark);
  border-radius: 1px;
  box-shadow: inset 0 1px 1px black, 0 1px 0 var(--pda-shell-highlight);
}

/* ==========================================================================
   2. 液晶显示屏 (LCD Screen)
   ========================================================================== */
#pda-screen-bezel {
  width: 100%;
  padding: 10px;
  background-color: #3b3e3c;
  border-radius: 12px;
  box-shadow:
    inset 0 3px 5px black,
    0 1px 2px var(--pda-shell-highlight);
  margin-bottom: 12px;
}

#pda-screen-contrast-layer {
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  transition: filter 0.2s ease;
}

#pda-screen-backlight {
  width: 100%;
  aspect-ratio: 1;
  background-color: var(--lcd-bg-off);
  position: relative;
  transition: background-color 0.45s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 4px 6px rgba(0, 0, 0, 0.4);
}

/* 屏幕边缘偏振冷光漏光层 */
#pda-screen-backlight::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1);

  /* 不均匀的老式发光板漏光：边缘偏冷光，角落略强 */
  background:
    radial-gradient(ellipse at 10% 20%, rgba(163, 255, 214, 0.35) 0%, rgba(163, 255, 214, 0) 55%),
    radial-gradient(ellipse at 90% 15%, rgba(163, 255, 214, 0.28) 0%, rgba(163, 255, 214, 0) 50%),
    radial-gradient(ellipse at 85% 85%, rgba(163, 255, 214, 0.32) 0%, rgba(163, 255, 214, 0) 60%),
    radial-gradient(ellipse at 15% 90%, rgba(163, 255, 214, 0.25) 0%, rgba(163, 255, 214, 0) 48%),
    radial-gradient(ellipse at 50% 50%, rgba(163, 255, 214, 0.08) 0%, rgba(163, 255, 214, 0) 70%);
}

#pda-screen-backlight.backlight-on {
  background-color: var(--lcd-backlight);
  box-shadow:
    inset 0 4px 6px rgba(0, 0, 0, 0.2),
    inset 0 0 18px rgba(163, 255, 214, 0.25),
    0 0 12px rgba(163, 255, 214, 0.45),
    0 0 28px rgba(163, 255, 214, 0.2);
}

#pda-screen-backlight.backlight-on::before {
  opacity: 1;
}

/* 液晶点阵偏振片网格纹理 (采用 CSS 渐变生成的精密斜纹点阵，实现真实感) */
#pda-lcd-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  background-size: 2px 2px;
  pointer-events: none;
  z-index: 2;
}

#pda-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated; /* 防止模糊，保留硬朗像素格 */
  position: relative;
  z-index: 1;
  mix-blend-mode: multiply; /* 墨汁效果混色 */
}

/* ==========================================================================
   3. 手写输入区 (Graffiti Area)
   ========================================================================== */
#pda-graffiti-bezel {
  width: 100%;
  padding: 6px 10px;
  background-color: #5d615e;
  border-radius: 8px;
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.5),
    0 1px 1px var(--pda-shell-highlight);
  margin-bottom: 16px;
}

#pda-graffiti-panel {
  width: 100%;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}

#pda-graffiti-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  mix-blend-mode: multiply;
  opacity: 0.65;
}

.graffiti-divider {
  position: absolute;
  left: 50%;
  top: 5px;
  bottom: 5px;
  width: 1px;
  border-left: 1px dashed rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.graffiti-icon {
  position: absolute;
  font-size: 11px;
  color: rgba(0,0,0,0.4);
  pointer-events: none;
  font-family: monospace;
}
.memo-shortcut { left: 8px; top: 13px; }
.sketch-shortcut { right: 8px; top: 13px; }

/* ==========================================================================
   4. 实体物理按键
   ========================================================================== */
#pda-controls {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
}

/* 按钮基础样式 (橡胶实体按键) */
.pda-btn {
  background-color: #555856;
  border: 1px solid #2a2c2b;
  color: #c8ccc9;
  cursor: pointer;
  outline: none;
  font-family: var(--font-pda);
  font-weight: bold;

  /* 橡胶质感：多层高光与投影 */
  box-shadow:
    0 4px 0 #202221,
    inset 0 1px 2px rgba(255, 255, 255, 0.25),
    inset 0 -2px 3px rgba(0, 0, 0, 0.35),
    0 5px 8px rgba(0, 0, 0, 0.35);
  transition: all 0.06s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.pda-btn::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(0,0,0,0.06) 100%);
  pointer-events: none;
}

.pda-btn:active, .pda-btn.pressed {
  box-shadow:
    0 1px 0 #202221,
    inset 0 3px 6px rgba(0, 0, 0, 0.65),
    inset 0 5px 10px rgba(0, 0, 0, 0.45),
    inset 0 1px 1px rgba(255, 255, 255, 0.08);
  transform: translateY(4px);
}

.circular-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#btn-power {
  background-color: #923a3a;
  box-shadow:
    0 4px 0 #4a1717,
    inset 0 1px 2px rgba(255, 180, 180, 0.35),
    inset 0 -2px 3px rgba(0, 0, 0, 0.3),
    0 5px 8px rgba(0, 0, 0, 0.35);
}
#btn-power:active, #btn-power.pressed {
  box-shadow:
    0 1px 0 #4a1717,
    inset 0 3px 6px rgba(0, 0, 0, 0.65),
    inset 0 5px 10px rgba(0, 0, 0, 0.45),
    inset 0 1px 1px rgba(255, 255, 255, 0.1);
  transform: translateY(4px);
}

/* 十字方向键 */
#pda-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dpad-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.dpad-btn {
  width: 38px;
  height: 28px;
  border-radius: 4px;
  font-size: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.select-btn {
  width: 44px;
  height: 34px;
  border-radius: 6px;
  background-color: #6d706e;
  font-size: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ==========================================================================
   5. 右侧控制项 (旋钮与手写笔)
   ========================================================================== */
#pda-side-controls {
  position: absolute;
  right: -45px;
  top: 100px;
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* 纵向对比度滑块 (模拟物理拨盘) */
.knob-label {
  font-size: 8px;
  color: #8c8f8b;
  transform: rotate(-90deg);
  margin-bottom: 20px;
  letter-spacing: 1px;
}

#pda-contrast-knob {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 8px;
  height: 80px;
  background-color: #3b3e3c;
  outline: none;
  cursor: pointer;
  border-radius: 4px;
}

/* 手写笔插槽 */
#pda-stylus-slot {
  width: 14px;
  height: 180px;
  background-color: var(--pda-shell-dark);
  border-radius: 7px;
  box-shadow: inset 3px 0 5px black;
  position: relative;
  cursor: pointer;
}

#pda-stylus {
  width: 10px;
  height: 176px;
  background: linear-gradient(90deg, #c8ccc9, #6d706e);
  border-radius: 5px;
  position: absolute;
  left: 2px;
  top: 2px;
  box-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#pda-stylus.docked {
  transform: translateY(0);
}

#pda-stylus.drawn {
  transform: translateY(-160px);
}

/* 当手写笔拔出时，指针样式改变 */
body.stylus-mode {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 21l3.5-3.5 12.5-12.5 3.5 3.5-12.5 12.5zm18-18l3 3-2 2-3-3z" fill="%23c8ccc9" stroke="black" stroke-width="1.5"/></svg>') 0 20, auto !important;
}

/* ==========================================================================
   6. 外部控制面板 (Dashboard)
   ========================================================================== */
#dashboard {
  flex: 1;
  min-width: 320px;
  max-width: 500px;
  background-color: var(--dashboard-bg);
  border-radius: 16px;
  padding: 30px;
  box-shadow:
    0 15px 30px rgba(0,0,0,0.3),
    inset 0 1px 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#dashboard h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #a3ffd6, #8bad0f);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#dashboard p {
  font-size: 14px;
  line-height: 1.6;
  color: #afb3b0;
  margin-bottom: 24px;
}

.dashboard-section {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  border-left: 4px solid var(--pda-shell-bg);
}

.dashboard-section h3 {
  font-size: 15px;
  margin-bottom: 8px;
  color: var(--text-color);
}

.dashboard-section ul {
  list-style-position: inside;
  font-size: 13px;
  line-height: 1.8;
  color: #afb3b0;
}

kbd {
  background-color: #444;
  border: 1px solid #666;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  color: white;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  margin-bottom: 12px;
}

.status-row:last-child {
  margin-bottom: 0;
}

.status-row button {
  background-color: #4f5250;
  border: 1px solid #333;
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s;
}

.status-row button:hover {
  background-color: #5f6260;
}

.status-row input[type="range"] {
  accent-color: var(--lcd-bg-off);
}
