/* Page-specific styles for /thinking/ and individual writing pages.
   This file is additive. It does not require changes to your existing styles.css. */

html,
body {
  overflow-x: hidden;
}

.site-border {
  z-index: 0;
}

.container {
  z-index: 2;
}

body:has(.card--thinking) {
  background: #d2d8c4;   /* or any color you want */
}

/* small folder-tab back button for derivative pages */

.page-back,
.page-back:visited {
  position: absolute;
  top: 24px;
  left: 38px;
  z-index: 160;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 34px;
  padding: 0 12px;
  background: var(--hover-yellow, #fecf43);
  color: var(--ink, #0a0a0a) !important;
  border: 1px solid rgba(10, 10, 10, 0.65);
  box-shadow:
    0 0 0 0.35px rgba(10, 10, 10, 0.34),
    2px 2px 0 rgba(41, 36, 30, 0.28);
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1;
  transform: translateY(0) scaleX(1) scaleY(1);
  transform-origin: center center;
  transition:
    background-color 180ms ease,
    transform 190ms cubic-bezier(0.2, 0.9, 0.25, 1.05),
    box-shadow 180ms ease,
    filter 180ms ease;
}

.page-back:hover {
  background: var(--lavender, #ccb8d4);
  color: var(--ink, #0a0a0a) !important;
  transform: translateY(0) scaleX(1.01) scaleY(0.975);
  box-shadow:
    0 0 0 0.35px rgba(10, 10, 10, 0.34),
    1px 1px 0 rgba(41, 36, 30, 0.22);
}

.page-back:active {
  transform: translateY(1px) scaleX(1.015) scaleY(0.94);
  box-shadow:
    0 0 0 0.35px rgba(10, 10, 10, 0.26),
    0 0.5px 0 rgba(10, 10, 10, 0.08);
}

/* thinking page */

.card--thinking {
  position: relative;
  width: min(760px, 100%);
}

.inner--thinking {
  min-height: 430px;
  padding-bottom: 76px;
}

.thinking-intro {
  margin-bottom: 18px;
}

/* writing index */

.writing-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  font-size: 0.78rem;
  line-height: 1.42;
}

.writing-list__item {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid rgba(10, 10, 10, 0.22);
}

.writing-list__link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 52px;
  padding: 0.72rem 0;
  color: inherit;
  text-decoration: none;
}

.writing-list__title {
  display: inline-block;
  max-width: 100%;
  line-height: 1.45;
  color: inherit;
  text-decoration: none;
  transition: color 160ms ease;
}

.writing-list__date {
  opacity: 0.62;
  white-space: nowrap;
  color: inherit;
}

.writing-list__link:hover .writing-list__title {
  color: var(--lavender, #ccb8d4);
}

.writing-list__link:active .writing-list__title {
  transform: translateY(1px);
}

.writing-list__empty {
  opacity: 0.62;
}

/* writing page controlled long-card illusion */

html:has(.card--writing),
body:has(.card--writing) {
  height: 100%;
  overflow: hidden;
}

body:has(.card--writing) {
  display: block;
  min-height: 100vh;
  padding: 0;
   background: var(--lavender); 
}

body:has(.card--writing) .container {
  min-height: 100vh;
  display: block;
}

.card--writing {
  width: min(860px, calc(100% - 48px));
  height: calc(
    100vh
    - var(--writing-card-offset, 88px)
    + var(--writing-bottom-overhang, 28px)
    - var(--writing-bottom-reveal, 0px)
  );
  max-height: calc(
    100vh
    - var(--writing-card-offset, 88px)
    + var(--writing-bottom-overhang, 28px)
    - var(--writing-bottom-reveal, 0px)
  );
  position: fixed;
  top: var(--writing-card-offset, 88px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 52px 24px 0;
  box-sizing: border-box;
}

.inner--writing {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding: 0;
  border-bottom: 0 !important;
}

.card--writing .writing-title {
  position: absolute;
  top: -0.92rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  display: block;
  width: fit-content;
  max-width: calc(100% - 160px);
  margin: 0;
  padding: 0 30px;
  background: var(--paper, #f4eedf);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

/* the article viewport starts below the title zone.
   no mask. no fake blank layer. */

.writing-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 28px;
  padding: 0 28px;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.writing-scroll::-webkit-scrollbar {
  display: none;
}

/* bottom inner whisker: appears only at the true end of the writing */

.writing-scroll::after {
  content: "";
  display: block;
  width: calc(100% + 56px);
  margin-left: -28px;
  margin-top: 28px;
  margin-bottom: 42px;
  border-bottom: 1px solid rgba(10, 10, 10, 0.55);
}

.writing-body {
  width: min(100%, 580px);
  max-width: none;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
  padding: 0 0 24px;
  overflow: visible;
  font-family: Futura, "Futura PT", "Trebuchet MS", Arial, sans-serif !important;
  font-weight: 400 !important;
  text-transform: none;
  letter-spacing: 0;
}

.writing-body p,
.writing-body li,
.writing-body blockquote {
  font-family: Futura, "Futura PT", "Trebuchet MS", Arial, sans-serif !important;
  font-weight: 400 !important;
}

.writing-body strong,
.writing-body b {
  font-weight: 600;
}

.writing-body p {
  margin: 0 0 1em;
}

.writing-body h2,
.writing-body h3 {
  margin: 1.6em 0 0.6em;
  font-size: 0.92rem;
  line-height: 1.2;
  font-weight: 500;
}

.writing-body ul,
.writing-body ol {
  margin: 0 0 1em;
  padding-left: 1.2em;
}

.writing-body li {
  margin-bottom: 0.35em;
}

.writing-body blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 1px solid rgba(10, 10, 10, 0.35);
}

.writing-body a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.08em;
}

.writing-body pre,
.writing-body code {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.writing-body pre {
  overflow-x: hidden;
}

/* writing images */

.writing-body img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 1.4rem auto 0.45rem;
  border: 1px solid rgba(10, 10, 10, 0.28);
}

.writing-body p:has(img) {
  margin: 1.8rem 0 0.4rem;
}

.writing-body p:has(img) + p em {
  display: block;
  max-width: 92%;
  margin: 0 auto 1.4rem;
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: center;
  opacity: 0.72;
}

.card--writing .writing-body,
.card--writing .writing-body * {
  text-transform: none !important;
}


/* mobile */

@media (max-width: 700px) {
  body:has(.card--writing) {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 18px;
    overflow: auto;
  }

  body:has(.card--writing) .container {
    min-height: auto;
  }

  .card--thinking,
  .card--writing {
    width: min(100%, 100%);
  }

  .card--writing {
    height: auto;
    max-height: none;
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    padding: 24px;
  }

  .page-back,
  .page-back:visited {
    top: 14px;
    left: 18px;
    min-width: 54px;
    height: 32px;
  }

  .inner--writing {
    display: block;
    overflow: visible;
    padding: 40px 16px 76px;
    border-bottom: 1px solid rgba(10, 10, 10, 0.55) !important;
  }

  .card--writing .writing-title {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    display: block;
    margin: -54px auto 28px;
    width: fit-content;
    max-width: 100%;
  }

  .writing-scroll {
    overflow: visible;
    margin-top: 0;
    padding: 0;
  }

  .writing-scroll::after {
    display: none;
  }

  .writing-body {
    width: 100%;
    padding: 0;
  }

  .writing-list__link {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    min-height: 58px;
  }

  .writing-list__date {
    display: block;
  }
}

