@font-face {
  font-family: 'Departure Mono';
  src: url('../fonts/DepartureMono-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

.page-dotmatrix {
  padding: 20px 0 80px 0;
  width: 100%;
}

.dotmatrix-wrapper {
  max-width: 900px;
  margin: 0 auto;
  margin-top: 180px; /* Pushed down to allow image to stick out */
  position: relative;
  /* Drop shadow natively outlines transparent holes and torn edges */
  filter: drop-shadow(0 5px 15px rgba(0,0,0,0.3));
}

.torn-top {
  height: 20px;
  background-color: white;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='20' preserveAspectRatio='none'%3E%3Cpath d='M0,20 L0,12 L4,10 L9,13 L12,11 L17,12 L21,9 L25,11 L30,12 L33,9 L39,11 L44,13 L48,10 L55,12 L60,9 L63,11 L68,12 L74,10 L79,13 L83,11 L89,12 L93,9 L98,11 L102,12 L107,10 L114,13 L119,11 L125,12 L129,9 L134,11 L140,12 L145,10 L148,12 L154,11 L159,13 L163,10 L169,12 L173,9 L178,11 L184,12 L189,10 L193,12 L198,11 L200,12 L200,20 Z' fill='black'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='20' preserveAspectRatio='none'%3E%3Cpath d='M0,20 L0,12 L4,10 L9,13 L12,11 L17,12 L21,9 L25,11 L30,12 L33,9 L39,11 L44,13 L48,10 L55,12 L60,9 L63,11 L68,12 L74,10 L79,13 L83,11 L89,12 L93,9 L98,11 L102,12 L107,10 L114,13 L119,11 L125,12 L129,9 L134,11 L140,12 L145,10 L148,12 L154,11 L159,13 L163,10 L169,12 L173,9 L178,11 L184,12 L189,10 L193,12 L198,11 L200,12 L200,20 Z' fill='black'/%3E%3C/svg%3E");
  -webkit-mask-size: 100% 20px;
  mask-size: 100% 20px;
  position: relative;
  z-index: 2;
}

.torn-bottom {
  height: 20px;
  background-color: white;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='20' preserveAspectRatio='none'%3E%3Cpath d='M0,0 L0,8 L4,10 L9,7 L12,9 L17,8 L21,11 L25,9 L30,8 L33,11 L39,9 L44,7 L48,10 L55,8 L60,11 L63,9 L68,8 L74,10 L79,7 L83,9 L89,8 L93,11 L98,9 L102,8 L107,10 L114,7 L119,9 L125,8 L129,11 L134,9 L140,8 L145,10 L148,8 L154,9 L159,7 L163,10 L169,8 L173,11 L178,9 L184,8 L189,10 L193,8 L198,9 L200,8 L200,0 Z' fill='black'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='20' preserveAspectRatio='none'%3E%3Cpath d='M0,0 L0,8 L4,10 L9,7 L12,9 L17,8 L21,11 L25,9 L30,8 L33,11 L39,9 L44,7 L48,10 L55,8 L60,11 L63,9 L68,8 L74,10 L79,7 L83,9 L89,8 L93,11 L98,9 L102,8 L107,10 L114,7 L119,9 L125,8 L129,11 L134,9 L140,8 L145,10 L148,8 L154,9 L159,7 L163,10 L169,8 L173,11 L178,9 L184,8 L189,10 L193,8 L198,9 L200,8 L200,0 Z' fill='black'/%3E%3C/svg%3E");
  -webkit-mask-size: 100% 20px;
  mask-size: 100% 20px;
  position: relative;
  z-index: 2;
}

.dotmatrix-paper {
  display: flex;
  background-color: transparent;
  min-height: 800px;
  position: relative;
  z-index: 1;
}

.perforation {
  width: 50px;
  flex-shrink: 0;
  /* 
    Holes: Transparent center, white background. 
    Drop-shadow on the wrapper will cast shadows through these holes!
  */
  background-image: radial-gradient(circle at center, transparent 7px, white 7.5px);
  background-size: 50px 72px;
  background-position: center top;
  position: relative;
}

.perforation.left {
  border-right: 2px dotted #aaa;
}

.perforation.right {
  border-left: 2px dotted #aaa;
}

.dotmatrix-content {
  flex-grow: 1;
  background-image: repeating-linear-gradient(
    to bottom,
    #ffffff,
    #ffffff 72px,
    #dcf0f9 72px,
    #dcf0f9 144px
  );
  padding: 24px 40px; 
  color: #111;
  font-size: 16px;
  line-height: 24px;
  overflow: hidden;
}

/* Aggressively enforce Departure Mono for the title and ALL content text */
.page-dotmatrix .dotmatrix-title,
.page-dotmatrix .dotmatrix-content,
.page-dotmatrix .dotmatrix-content p,
.page-dotmatrix .dotmatrix-content h1,
.page-dotmatrix .dotmatrix-content h2,
.page-dotmatrix .dotmatrix-content h3,
.page-dotmatrix .dotmatrix-content h4,
.page-dotmatrix .dotmatrix-content h5,
.page-dotmatrix .dotmatrix-content h6,
.page-dotmatrix .dotmatrix-content ul,
.page-dotmatrix .dotmatrix-content ol,
.page-dotmatrix .dotmatrix-content li,
.page-dotmatrix .dotmatrix-content blockquote,
.page-dotmatrix .dotmatrix-content a,
.page-dotmatrix .dotmatrix-content span,
.page-dotmatrix .dotmatrix-content strong,
.page-dotmatrix .dotmatrix-content em,
.page-dotmatrix .dotmatrix-content pre,
.page-dotmatrix .dotmatrix-content code {
  font-family: 'Departure Mono', monospace !important;
}

/* Ensure content rhythm matches the 24px baseline */
.dotmatrix-content p,
.dotmatrix-content ul,
.dotmatrix-content ol,
.dotmatrix-content blockquote,
.dotmatrix-content figure {
  margin: 0 0 24px 0;
  padding: 0;
}

.dotmatrix-content h1,
.dotmatrix-content h2,
.dotmatrix-content h3,
.dotmatrix-content h4,
.dotmatrix-content h5,
.dotmatrix-content h6 {
  margin: 0 0 24px 0;
  padding: 0;
  font-weight: bold;
}

.dotmatrix-content h1 {
  font-size: 32px;
  line-height: 48px;
}

.dotmatrix-content h2 {
  font-size: 24px;
  line-height: 48px;
}

.dotmatrix-content h3 {
  font-size: 18px;
  line-height: 24px;
}

.dotmatrix-content ul,
.dotmatrix-content ol {
  padding-left: 20px;
}

.dotmatrix-content li {
  margin-bottom: 0;
}

.dotmatrix-content pre,
.dotmatrix-content code {
  font-size: 16px;
  line-height: 24px;
  color: #111;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
}

.dotmatrix-content pre {
  margin-bottom: 24px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

@media (max-width: 768px) {
  .dotmatrix-paper {
    flex-direction: column;
  }
  .perforation {
    display: none;
  }
  .dotmatrix-content {
    padding: 24px 20px;
  }
  .dotmatrix-featured-image {
    top: -60px;
    left: 20px;
    width: 80%;
  }
  .dotmatrix-title {
    font-size: 32px;
    line-height: 48px;
  }
}

.dotmatrix-featured-image {
  position: absolute;
  top: -80px;
  left: 5%;
  width: 50%;
  max-width: 400px;
  transform: rotate(-6deg);
  z-index: 0;
  margin: 0;
  padding: 0;
}

.dotmatrix-featured-image img {
  display: block;
  width: 100%;
  height: auto;
  border: 10px solid #fdfdfd;
  border-bottom-width: 30px; /* Polaroid aesthetic */
  /* Do not add box-shadow here; wrapper's drop-shadow applies automatically! */
}

.dotmatrix-title {
  font-size: 48px;
  line-height: 48px;
  margin: 0 0 48px 0;
  text-align: center;
  text-transform: uppercase;
  font-weight: bold;
}
