/* ===== Font Face ===== */
@font-face {
  font-family: 'JMH Typewriter';
  src: url('fonts/JMH Typewriter.otf') format('opentype'),
       url('fonts/JMH Typewriter.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'JMH Typewriter';
  src: url('fonts/JMH Typewriter-Bold.otf') format('opentype'),
       url('fonts/JMH Typewriter-Bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'JMH Typewriter', 'Courier New', monospace;
  background: #3b3530;
}

/* ===== Layout ===== */
body {
  display: flex;
}

/* ===== Left Sidebar ===== */
.sidebar {
  width: 48px;
  min-width: 48px;
  background: #2c2824;
  border-right: 2px solid #4a433d;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
  transition: width 0.3s ease, min-width 0.3s ease;
  overflow: hidden;
  z-index: 10;
}

.sidebar.expanded {
  width: 200px;
  min-width: 200px;
}

/* Burger Button */
.burger-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.burger-btn:hover {
  background: rgba(255,255,255,0.08);
}

.burger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: #c4b5a0;
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.sidebar.expanded .burger-btn span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.sidebar.expanded .burger-btn span:nth-child(2) {
  opacity: 0;
}
.sidebar.expanded .burger-btn span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Sidebar Menu */
.sidebar-menu {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 16px 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.sidebar.expanded .sidebar-menu {
  opacity: 1;
  pointer-events: all;
}

.menu-btn {
  background: none;
  border: none;
  color: #c4b5a0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  width: 100%;
  font-family: 'JMH Typewriter', monospace;
  font-size: 13px;
  text-align: left;
  transition: background 0.2s;
  white-space: nowrap;
}

.menu-btn:hover {
  background: rgba(255,255,255,0.06);
}

.menu-label {
  opacity: 0;
  transition: opacity 0.2s;
}

.sidebar.expanded .menu-label {
  opacity: 1;
}

/* Sidebar Logo */
.sidebar-logo {
  padding: 8px 10px 16px;
  border-bottom: 1px solid #4a433d;
  margin-bottom: 8px;
  text-align: center;
}

.logo-text {
  font-family: 'JMH Typewriter', 'Courier New', monospace;
  font-size: 20px;
  font-weight: bold;
  color: #d4c5b0;
  letter-spacing: 0.5px;
  line-height: 1.3;
}

.logo-overlap {
  display: inline-block;
  position: relative;
  width: 0.6em;
}

.logo-under {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  text-align: center;
  opacity: 0.55;
  transform: translateY(-0.3px) rotate(-0.5deg);
}

.logo-over {
  position: relative;
  display: inline-block;
  width: 100%;
  text-align: center;
  transform: translateY(0.2px) rotate(0.3deg);
}

/* Menu Separator & Sections */
.menu-separator {
  height: 1px;
  background: #4a433d;
  margin: 8px 16px;
}

.menu-section {
  padding: 0;
}

.section-title {
  display: block;
  font-size: 11px;
  color: #8a7d70;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* Theme Toggle */
.theme-toggle-btn {
  position: relative;
}

.theme-chevron {
  position: absolute;
  right: 12px;
  transition: transform 0.2s;
  opacity: 0;
}

.sidebar.expanded .theme-chevron {
  opacity: 1;
}

.theme-toggle-btn.open .theme-chevron {
  transform: rotate(180deg);
}

/* Theme List */
.theme-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 16px 8px;
  max-height: 300px;
  overflow-y: auto;
  transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.2s;
}

.theme-list.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border: none;
  background: none;
  color: #c4b5a0;
  font-family: 'JMH Typewriter', monospace;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
  text-align: left;
  white-space: nowrap;
  width: 100%;
}

.theme-option:hover {
  background: rgba(255,255,255,0.06);
}

.theme-option.active {
  background: rgba(255,255,255,0.1);
}

.theme-preview {
  width: 24px;
  height: 32px;
  border-radius: 2px;
  border: 1px solid #5a5047;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

/* ===== Right Sidebar ===== */
.sidebar-right {
  width: 48px;
  min-width: 48px;
  background: #2c2824;
  border-left: 2px solid #4a433d;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
  background: #3b3530;
}

/* ===== Paper ===== */
.paper-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 40px;
  padding-bottom: 40px;
}

.paper-page {
  width: 720px;
  height: 1018px;
  background-image: url('white-texture.jpg');
  background-size: cover;
  background-repeat: repeat;
  border-radius: 2px;
  box-shadow:
    0 2px 20px rgba(0,0,0,0.4),
    inset 0 0 60px rgba(0,0,0,0.03);
  padding: 60px 65px;
  position: relative;
  cursor: text;
  font-family: 'JMH Typewriter', 'Courier New', monospace;
  font-size: 16px;
  line-height: 28px;
  color: #1a1410;
  letter-spacing: 0.5px;
  white-space: pre;
  overflow: hidden;
}



/* ===== Paper Content (container for pages) ===== */
.paper-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  padding-bottom: 40px;
}

/* ===== Typed Lines ===== */
.typed-line {
  position: relative;
  height: 28px;
  white-space: pre;
}

/* Individual character cell */
.typed-char {
  display: inline-block;
  width: 9.6px; /* monospace char width */
  text-align: center;
  position: relative;
  height: 1em;
}

/* Character layer (stacked on same position) */
.char-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  text-align: center;
}

.char-layer:first-child {
  position: relative;
}

/* Overlap layers get slight offset for realism */
.char-layer.char-overlap {
  opacity: 0.85;
}

/* ===== Cursor ===== */
.cursor-line {
  position: relative;
}

.typewriter-cursor {
  display: inline-block;
  position: absolute;
  top: 70%;
  font-family: 'JMH Typewriter', monospace;
  font-size: 15px;
  line-height: 1;
  color: #8b0000;
  pointer-events: none;
  font-weight: bold;
}

/* ===== End of Line Indicator ===== */
.eol-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(139, 0, 0, 0.85);
  color: #f5e6d0;
  padding: 12px 28px;
  border-radius: 4px;
  font-family: 'JMH Typewriter', monospace;
  font-size: 18px;
  letter-spacing: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  z-index: 100;
}

.eol-indicator.show {
  opacity: 1;
}

/* ===== Ink Effects ===== */
/* Slight random ink variation */
.ink-light { opacity: 0.75; }
.ink-normal { opacity: 0.9; }
.ink-heavy { opacity: 1; color: #0d0a08; }

/* Slight vertical jitter per character */
.jitter-1 { transform: translateY(-0.3px); }
.jitter-2 { transform: translateY(0.4px); }
.jitter-3 { transform: translateY(-0.2px) rotate(-0.3deg); }
.jitter-4 { transform: translateY(0.2px) rotate(0.2deg); }

/* ===== Bottom Bar (zoom + page counter) ===== */
.bottom-bar {
  position: fixed;
  bottom: 16px;
  right: 64px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 50;
  user-select: none;
}

.bottom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2c2824;
  border: 1px solid #4a433d;
  border-radius: 4px;
  color: #c4b5a0;
  width: 34px;
  height: 34px;
  cursor: pointer;
  transition: background 0.15s;
}

.bottom-btn:hover {
  background: #3b3530;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #2c2824;
  border: 1px solid #4a433d;
  border-radius: 4px;
  padding: 2px 6px;
}

.zoom-btn {
  background: none;
  border: none;
  color: #c4b5a0;
  font-size: 18px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.zoom-btn:hover {
  background: rgba(255,255,255,0.08);
}

.zoom-level {
  color: #c4b5a0;
  font-family: 'JMH Typewriter', monospace;
  font-size: 12px;
  min-width: 40px;
  text-align: center;
}

.page-counter {
  background: #2c2824;
  color: #c4b5a0;
  font-family: 'JMH Typewriter', monospace;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid #4a433d;
  letter-spacing: 1px;
}

/* ===== Scrollbar ===== */
.main-content::-webkit-scrollbar {
  width: 8px;
}
.main-content::-webkit-scrollbar-track {
  background: #2c2824;
}
.main-content::-webkit-scrollbar-thumb {
  background: #5a5047;
  border-radius: 4px;
}
.main-content::-webkit-scrollbar-thumb:hover {
  background: #6a6057;
}

/* ===== Selection prevention ===== */
.paper-content ::selection {
  background: transparent;
}

.paper-content ::-moz-selection {
  background: transparent;
}

/* ===== Sidebar bottom sections ===== */
.sidebar-menu {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 16px 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  height: calc(100vh - 60px);
  overflow-y: auto;
}

.sidebar-bottom-section {
  padding: 4px 0;
  border-top: 1px solid #4a433d;
}

/* ===== Storage Bar ===== */
.storage-bar-wrap {
  padding: 8px 16px;
}

.storage-bar {
  width: 100%;
  height: 6px;
  background: #1a1714;
  border-radius: 3px;
  overflow: hidden;
}

.storage-bar.large {
  height: 10px;
  margin: 8px 0;
}

.storage-fill {
  height: 100%;
  background: #8b9a6d;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.storage-fill.warning {
  background: #c49a3c;
}

.storage-fill.full {
  background: #8b0000;
}

.storage-label {
  font-size: 10px;
  color: #8a7d70;
  display: block;
  margin-top: 4px;
}

.upgrade-btn {
  color: #c4a84d !important;
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: #2c2824;
  border: 1px solid #4a433d;
  border-radius: 8px;
  width: 420px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  color: #c4b5a0;
  font-family: 'JMH Typewriter', monospace;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #8a7d70;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #c4b5a0;
}

.modal-title {
  font-size: 18px;
  color: #d4c5b0;
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.modal-body {
  font-size: 13px;
  line-height: 1.6;
}

.modal-body ul {
  margin: 8px 0 8px 20px;
}

.modal-body li {
  margin-bottom: 4px;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  background: #1a1714;
  border: 1px solid #4a433d;
  border-radius: 4px;
  color: #c4b5a0;
  font-family: 'JMH Typewriter', monospace;
  font-size: 13px;
  margin-bottom: 10px;
  outline: none;
}

.modal-input:focus {
  border-color: #6a6057;
}

.modal-btn {
  width: 100%;
  padding: 10px;
  background: #5a5047;
  border: none;
  border-radius: 4px;
  color: #d4c5b0;
  font-family: 'JMH Typewriter', monospace;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s;
  margin-top: 4px;
}

.modal-btn:hover {
  background: #6a6057;
}

.modal-btn.secondary {
  background: #3b3530;
  margin-top: 16px;
}

.modal-btn.secondary:hover {
  background: #4a433d;
}

/* Auth tabs */
.auth-toggle {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  background: #1a1714;
  border-radius: 4px;
  overflow: hidden;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: #8a7d70;
  font-family: 'JMH Typewriter', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
  background: #4a433d;
  color: #d4c5b0;
}

.auth-error {
  color: #c44d4d;
  font-size: 12px;
  margin-bottom: 8px;
  min-height: 16px;
}

.storage-info {
  margin: 12px 0;
}

/* ===== Document list items ===== */
.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 20px;
}

.doc-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-rename-input {
  width: 100%;
  background: #1a1714;
  border: 1px solid #6a6057;
  border-radius: 2px;
  color: #c4b5a0;
  font-family: 'JMH Typewriter', monospace;
  font-size: 12px;
  padding: 1px 4px;
  outline: none;
}

.doc-delete {
  background: none;
  border: none;
  color: #6a5047;
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  flex-shrink: 0;
}

.doc-delete:hover {
  color: #8b0000;
}

/* ===== Storage full banner ===== */
.storage-full-banner {
  position: fixed;
  top: 0;
  left: 48px;
  right: 48px;
  background: #8b0000;
  color: #f5e6d0;
  text-align: center;
  padding: 8px;
  font-family: 'JMH Typewriter', monospace;
  font-size: 13px;
  z-index: 150;
}

.inline-link {
  background: none;
  border: none;
  color: #f5e6d0;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}
