/* Letter Page Styles
   Extracted from letters/on-reputational-wealth/index.html
   ======================================================== */

@layer content {
  /* Letter Container */
  .letter-container {
    max-width: 720px;
    margin: 0 auto;
    background: var(--stationery);
    padding: 3rem 3.5rem 4rem;
    position: relative;
    z-index: 1;
    box-shadow: 
      0 2px 4px var(--shadow),
      0 8px 24px var(--shadow-strong),
      0 24px 48px rgba(28, 24, 20, 0.15);
  }

  /* Ruled lines effect */
  .letter-container::before {
    content: '';
    position: absolute;
    top: 180px;
    left: 3.5rem;
    right: 3.5rem;
    bottom: 4rem;
    background: repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 28px,
      rgba(28, 24, 20, 0.04) 28px,
      rgba(28, 24, 20, 0.04) 29px
    );
    pointer-events: none;
    z-index: 0;
  }

  /* Red margin line */
  .letter-container::after {
    content: '';
    position: absolute;
    top: 180px;
    left: 3rem;
    bottom: 4rem;
    width: 1px;
    background: rgba(180, 60, 60, 0.15);
    pointer-events: none;
  }

  /* Header */
  .letter-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(138, 106, 32, 0.2);
    position: relative;
    z-index: 1;
  }

  .letter-seal {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: var(--brass);
    opacity: 0.4;
  }

  .letter-title {
    font-size: 2.4rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 0.75rem;
    line-height: 1.2;
  }

  .letter-subtitle {
    font-size: 1.15rem;
    font-style: italic;
    color: var(--ink-soft);
    margin-bottom: 1rem;
  }

  .letter-meta {
    font-size: 0.85rem;
    color: var(--ink-faint);
  }

  .letter-meta time {
    font-weight: 500;
  }

  /* Letter stack edges - prev/next navigation */
  .letter-edge {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    text-decoration: none;
    z-index: 50;
    transition: all 0.2s ease;
  }

  .letter-edge-prev {
    left: 60px;
    transform: rotate(180deg);
    background: linear-gradient(90deg, 
      var(--stationery) 0%, 
      rgba(254, 252, 247, 0.95) 60%,
      rgba(254, 252, 247, 0.8) 100%
    );
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    border-right: 1px solid rgba(138, 106, 32, 0.1);
  }

  .letter-edge-next {
    right: 0;
    transform: rotate(180deg);
    background: linear-gradient(270deg, 
      var(--stationery) 0%, 
      rgba(254, 252, 247, 0.95) 60%,
      rgba(254, 252, 247, 0.8) 100%
    );
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    border-left: 1px solid rgba(138, 106, 32, 0.1);
  }

  .letter-edge span {
    font-family: var(--font-system);
    font-size: 0.55rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--ink-faint);
    transition: color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 200px;
  }

  .letter-edge:hover {
    width: 32px;
  }

  .letter-edge:hover span {
    color: var(--brass);
  }

  .letter-nav {
    display: none;
  }

  @media (max-width: 800px) {
    .letter-edge {
      display: none;
    }
  }

  /* Letter context - sticky note */
  .letter-context {
    background: #FFF2B8;
    background: linear-gradient(160deg, #FFF6CC 0%, #FFEC99 60%, #FFE066 100%);
    border: 1px solid rgba(180, 140, 20, 0.3);
    box-shadow: 
      0 1px 2px rgba(0,0,0,0.1),
      0 4px 12px rgba(0,0,0,0.08),
      0 12px 32px rgba(0,0,0,0.06);
    padding: 1.4rem 1.6rem 1.5rem;
    margin: 0 0 2.5rem;
    position: relative;
    transform: rotate(-1.5deg);
    max-width: 320px;
    font-family: var(--font-serif);
  }

  /* Tape effect */
  .letter-context::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%) rotate(1deg);
    width: 80px;
    height: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, rgba(235,230,210,0.7) 100%);
    border: 1px solid rgba(160,150,120,0.4);
    border-radius: 1px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }

  .letter-context-body {
    font-size: 1.05rem;
    color: #1A1610;
    line-height: 1.5;
    margin: 0 0 0.85rem 0;
  }

  .letter-context-why {
    font-size: 0.88rem;
    color: #4A4030;
    margin: 0;
    padding-top: 0.7rem;
    border-top: 1px solid rgba(120, 90, 20, 0.25);
    font-style: italic;
  }

  /* On larger screens, position to the side */
  @media (min-width: 900px) {
    .letter-context {
      position: absolute;
      right: -280px;
      top: 80px;
      margin: 0;
      transform: rotate(2deg);
    }
  }

  @media (min-width: 1100px) {
    .letter-context {
      right: -320px;
      max-width: 300px;
    }
  }

  @media (max-width: 899px) {
    .letter-context {
      max-width: none;
      transform: rotate(-0.5deg);
      margin: 0 0 2rem;
    }
  }

  /* Letter body */
  .letter-body {
    position: relative;
    z-index: 1;
  }

  .letter-salutation {
    font-size: 1.1rem;
    font-style: italic;
    color: var(--ink-soft);
    margin-bottom: 1.5rem;
  }

  .letter-body p {
    margin-bottom: 1.5rem;
    text-align: justify;
    hyphens: auto;
  }

  .letter-body h2 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--ink);
    margin: 3rem 0 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(138, 106, 32, 0.15);
  }

  .letter-body h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
    margin: 2rem 0 1rem;
  }

  .letter-body strong {
    font-weight: 600;
    color: var(--ink);
  }

  .letter-body em {
    font-style: italic;
  }

  .letter-body a {
    color: var(--brass);
    text-decoration: none;
    border-bottom: 1px solid rgba(138, 106, 32, 0.3);
    transition: border-color 0.2s ease;
  }

  .letter-body a:hover {
    border-color: var(--brass);
  }

  .letter-body ul, .letter-body ol {
    margin: 1.5rem 0;
    padding-left: 1.5rem;
  }

  .letter-body li {
    margin-bottom: 0.75rem;
  }

  .letter-body blockquote {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    background: rgba(138, 106, 32, 0.05);
    border-left: 3px solid var(--brass);
    font-style: italic;
    color: var(--ink-soft);
  }

  .letter-body blockquote p {
    margin-bottom: 0;
    text-align: left;
  }

  .letter-body hr {
    border: none;
    height: 1px;
    background: rgba(138, 106, 32, 0.2);
    margin: 2.5rem 0;
  }

  .letter-body code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: rgba(138, 106, 32, 0.08);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    color: var(--ink);
  }

  /* Inline figures */
  .letter-figure {
    margin: 2.5rem -1rem;
    padding: 0;
  }

  .letter-figure img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid rgba(138, 106, 32, 0.12);
  }

  .letter-figure figcaption {
    font-size: 0.8rem;
    color: var(--ink-faint);
    text-align: center;
    margin-top: 0.75rem;
    font-style: italic;
  }

  @media (min-width: 800px) {
    .letter-figure {
      margin: 2.5rem -2rem;
    }
  }

  /* Code blocks */
  .code-block {
    background: var(--ink);
    color: var(--daylight-bezel);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    border-radius: 4px;
  }

  .code-block code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
  }

  .code-comment { color: var(--ink-faint); }
  .code-keyword { color: var(--gold-light); }
  .code-string { color: #8AAA6A; }
  .code-type { color: #7AA8D4; }
  .code-function { color: #D4A47A; }

  /* Fractal summary box */
  .fractal-summary {
    background: var(--stationery);
    padding: 1.5rem 2rem;
    margin: 2rem 0;
    border: 1px solid rgba(138, 106, 32, 0.1);
  }

  .fractal-summary h3 {
    margin-top: 0;
  }

  /* Technical sections */
  .technical-list {
    background: var(--stationery);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
  }

  .technical-list ul {
    margin: 0.75rem 0;
  }

  /* Signature */
  .letter-signature {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(138, 106, 32, 0.2);
  }

  .letter-signature-name {
    font-size: 1.3rem;
    font-style: italic;
    color: var(--ink);
  }

  /* Postscript */
  .letter-postscript {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(138, 106, 32, 0.15);
  }

  .letter-postscript-label {
    font-size: 0.85rem;
    color: var(--ink-faint);
    margin-bottom: 1.25rem;
    font-style: italic;
  }

  .letter-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .letter-attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    background: var(--parchment);
    border: 1px solid rgba(138, 106, 32, 0.15);
    box-shadow: 1px 2px 4px rgba(0,0,0,0.04);
    font-size: 0.8rem;
    color: var(--ink-soft);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  }

  .letter-attachment:hover {
    border-color: rgba(138, 106, 32, 0.35);
    box-shadow: 2px 3px 8px rgba(0,0,0,0.08);
    z-index: 1;
  }

  .letter-attachment-icon {
    font-size: 0.65rem;
    color: var(--brass);
  }

  .letter-attachment-text {
    color: var(--ink-soft);
  }

  .letter-attachment:hover .letter-attachment-text {
    color: var(--ink);
  }

  /* Reply */
  .letter-reply {
    margin-top: 2.5rem;
    text-align: center;
    font-size: 0.95rem;
    color: var(--ink-soft);
  }

  .letter-reply a {
    color: var(--brass);
    text-decoration: none;
    border-bottom: 1px solid rgba(138, 106, 32, 0.3);
    transition: border-color 0.2s ease;
  }

  .letter-reply a:hover {
    border-color: var(--brass);
  }

  /* Footer */
  .letter-footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(138, 106, 32, 0.15);
    text-align: center;
    position: relative;
    z-index: 1;
  }

  .letter-footer-author {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }

  .letter-footer-seal {
    width: 48px;
    height: 48px;
    color: var(--brass);
    opacity: 0.6;
  }

  .letter-footer-name {
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }

  .letter-footer-tagline {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--ink-faint);
    max-width: 320px;
  }

  /* Responsive */
  @media (max-width: 800px) {
    .letter-container {
      padding: 2.5rem 2rem 3rem;
    }

    .letter-container::before {
      left: 2rem;
      right: 2rem;
      top: 160px;
    }

    .letter-container::after {
      left: 1.5rem;
      top: 160px;
    }
  }

  @media (max-width: 600px) {
    .letter-container {
      padding: 2rem 1.25rem 3rem;
      box-shadow: none;
      max-width: 100%;
    }

    .letter-container::before,
    .letter-container::after {
      display: none;
    }

    .letter-title {
      font-size: 1.9rem;
    }

    .letter-body h2 {
      font-size: 1.3rem;
    }

    .letter-body p {
      text-align: left;
      hyphens: none;
    }

    .fractal-summary,
    .technical-list {
      padding: 1.25rem 1rem;
      margin-left: -0.5rem;
      margin-right: -0.5rem;
    }

    .code-block {
      margin-left: -0.5rem;
      margin-right: -0.5rem;
      border-radius: 0;
    }
  }

  /* Print styles */
  @media print {
    .letter-container {
      box-shadow: none;
      max-width: 100%;
      padding: 0;
    }

    .letter-container::before,
    .letter-container::after {
      display: none;
    }

    .letter-back-fixed {
      display: none;
    }

    .letter-body a {
      color: var(--ink);
      border-bottom: none;
    }

    .letter-body a::after {
      content: " (" attr(href) ")";
      font-size: 0.8em;
      color: var(--ink-faint);
    }
  }
}
