/* ==========================================================================
   Structure:
   1. Base & Variables
   2. Layout
   3. Editor
   4. UI Elements
   5. Typography
   6. Header & Navigation
   7. Placeholder
   8. Animation & Transitions
   ========================================================================== */

/* ==========================================================================
   1. Base & Variables
   ========================================================================== */

:root {
  /* Color variables */
  --background-color: #fffef8;  /* Subtle cream background */
  --text-color: #333333;        /* Dark gray text */
  --subtle-color: #aaa;         /* Light gray for subtle elements */
  --hover-color: #777;          /* Darker gray for hover states */
  --accent-color: #ccc;         /* Border colors */
  --selection-color: #e3e3e3;   /* Text selection highlight */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--background-color);
  color: var(--text-color);
  font-family: 'Courier Prime', 'Courier New', monospace;
}

/* ==========================================================================
   2. Layout
   ========================================================================== */

.container {
  width: 750px; /* Changed from max-width to width */
  margin: 0 auto;
  padding: 2rem 1rem;
  position: relative;
}

/* ==========================================================================
   3. Editor
   ========================================================================== */

#editor {
  /* Core styling */
  width: 100%;
  min-height: 70vh;
  margin-top: 4rem;
  background-color: var(--background-color);
  color: var(--text-color);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  
  /* Typography */
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 1.2rem;
  line-height: 1.8;
  
  /* Behavior */
  border: none;
  outline: none;
  white-space: nowrap;
  overflow-x: hidden; /* Consistently use hidden */
  padding-right: 2rem; /* Add padding for safety */
  
  /* Prevent text selection (typewriter-like behavior) */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;

  /* Consistent character spacing */
  font-variant-ligatures: none;
  font-kerning: none;

  /* Makes the cursor invisible */
  caret-color: transparent;
}

/* Line styling for typewriter effect */
.editor-line {
  display: block;
  margin-bottom: 0.3em;
  position: relative;
  white-space: nowrap;
  overflow-x: hidden; /* Use hidden consistently */
  max-width: 100%; /* Ensure lines don't exceed container */
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Clips text so there is no overflow */
html body .container #editor .editor-line {
  max-width: 750px;
  text-overflow: clip;
  padding-right: 10px; /* Add this line */
}

/* Make sure line breaks maintain proper spacing */
#editor br {
  line-height: inherit;
}

/* Remove default paragraph margins */
#editor p {
  margin: 0;
}

/* Style text selection */
#editor::selection {
  background: var(--selection-color);
}

/* Page break styling for Cmd+Enter */
.page-break {
  border: none;
  border-top: 1px dashed var(--accent-color);
  margin: 2rem 0;
}

/* ==========================================================================
   4. UI Elements
   ========================================================================== */

/* Status logo in bottom left that shows save status */
#status-logo {
  border: 1.5px solid var(--subtle-color);
  color: var(--subtle-color);
}

/* Word count at bottom of viewport */
#wordcount {
  position: fixed;
  display: none;
  bottom: 1rem;
  left: 0;
  right: 0;
  font-size: 0.85rem;
  text-align: center;
  opacity: 0.7;
  pointer-events: none;
  z-index: 10;
  font-family: 'Special Elite', 'Courier Prime', 'Courier New', monospace;
}

/* ==========================================================================
   5. Typography
   ========================================================================== */

/* All links styling */
.meta-link {
  color: var(--subtle-color);
  text-decoration: none;
  margin: 0 0.5rem;
  transition: color 0.2s;
  padding-bottom: 1px;
}

.meta-link:hover {
  color: var(--text-color);
}

/* ==========================================================================
   6. Header & Navigation
   ========================================================================== */

/* Start with header completely hidden using display property */
.site-header {
    position: fixed;
    top: 1rem;
    left: 0;
    right: 0;
    z-index: 100;
    text-align: center;
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    /* Use display property initially */
    display: none;
}

/* Only when specifically shown */
.site-header.visible {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* When hidden after being visible */
.site-header.hidden {
    display: block;
    opacity: 0;
    pointer-events: none;
}

/* Links container */
.meta-links {
  margin-top: 1.5rem;
  font-size: 0.8rem;
}

/* Header links specific styling */
.site-header .meta-link {
  border-bottom: none;
}

.site-header .meta-link:hover {
  border-bottom: none;
}

/* Hide header when typing */
.site-header.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   7. Placeholder
   ========================================================================== */

/* Central placeholder shown when editor is empty */
#placeholder {
  position: absolute;
  color: var(--subtle-color);
  pointer-events: none;
  display: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-family: 'Special Elite', 'Courier Prime', 'Courier New', monospace;
}

/* Keyboard shortcuts section in placeholder */
#placeholder .shortcuts {
  font-style: normal;
  margin-top: 20px;
}

/* Logo in placeholder */
#logo {
  font-size: 3rem;
  margin: 1.5rem auto;
  width: 5rem;
  height: 5rem;
  line-height: 5rem;
  text-align: center;
  border: 2px solid var(--accent-color);
  border-radius: 50%;
  color: var(--subtle-color);
  font-family: 'Special Elite', 'Courier Prime', 'Courier New', monospace;
}

/* Links in placeholder */
#placeholder .meta-link {
  border-bottom: none;
}

#placeholder .meta-link:hover {
  color: var(--hover-color);
  border-bottom: 1px solid var(--accent-color);
}