// Basic color palette, from which variations will be derived.
@motorway:          #fc8;
@main:              #fea;
@street:            #fff;
@street_limited:    #f3f3f3;

@land:              #E8E0D8;

// ---------------------------------------------------------------------

 #roads {
  
  // casing/outlines & single lines
  ::case[zoom>=6]['mapnik::geometry_type'=2] {
    [or_rdclass='national'],[or_class='national'] {
      line-join:round;
      line-color: mix(@motorway, #800, 75);
      #road { line-cap: round; }
      [zoom>=6] { line-width:0.4; }
      [zoom>=7] { line-width:0.6; }
      [zoom>=8] { line-width:1.5; }
      [zoom>=10] { line-width:3; }
      [zoom>=13] { line-width:3.5;  }
      [zoom>=14] { line-width:5; }
      [zoom>=15] { line-width:7; }
      [zoom>=16] { line-width:9; }
    }
    [or_rdclass='provincial'],[or_class='provincial'] {
      line-join:round;
      line-color: mix(@main, #800, 75);
      #road { line-cap: round; }
      [zoom>=6] { line-width:0.2; }
      [zoom>=7] { line-width:0.4; }
      [zoom>=8] { line-width:1.5; }
      [zoom>=10] { line-width:2.4; }
      [zoom>=13] { line-width:2.5; }
      [zoom>=14] { line-width:4; }
      [zoom>=15] { line-width:5; }
      [zoom>=16] { line-width:8; }
    }
    [or_rdclass='municipal'][zoom>=12],[or_class='municipal'][zoom>=12],[or_rdclass='barangay'][zoom>=12],[or_class='barangay'][zoom>=12] {
      line-join:round;
      #road { line-cap: round; }
      line-color: @land * 0.8;
      [zoom>=12] { line-width:0.5; }
      [zoom>=14] { line-width:1; }
      [zoom>=15] { line-width:4; }
      [zoom>=16] { line-width:6.5; }
    }
    [or_rdclass='private'][zoom>=15],[or_class='private'][zoom>=15] {
      line-join:round;
      #road { line-cap: round; }
      line-color: @land * 0.9;
      [zoom>=15] { line-width:1; }
      [zoom>=16] { line-width:4; }
    }
  }
  
  // fill/inlines
  ::fill[zoom>=6]['mapnik::geometry_type'=2] {
    [or_rdclass='national'][zoom>=8],[or_class='national'][zoom>=8] {
      line-join:round;
      #road, #bridge { line-cap:round; }
      line-color:@motorway;
      [zoom>=8] { line-width:0.5; }
      [zoom>=10] { line-width:1; }
      [zoom>=13] { line-width:2; }
      [zoom>=14] { line-width:3.5; }
      [zoom>=15] { line-width:5; }
      [zoom>=16] { line-width:7; }
    }
    [or_rdclass='provincial'][zoom>=8],[or_class='provincial'][zoom>=8] {
      line-join:round;
      #road, #bridge { line-cap: round; }
      line-color:@main;
      [zoom>=8] { line-width:0.5; }
      [zoom>=10] { line-width:1; }
      [zoom>=13] { line-width:1.5; }
      [zoom>=14] { line-width:2.5; }
      [zoom>=15] { line-width:3.5; }
      [zoom>=16] { line-width:6; }
    }
    [or_rdclass='municipal'][zoom>=15],[or_class='municipal'][zoom>=15] {
      line-join:round;
      #road { line-cap: round; }
      [zoom>=15] { line-width:2.5; line-color:#fff; }
      [zoom>=16] { line-width:4; }
    }
    [or_rdclass='barangay'][zoom>=15],[or_class='barangay'][zoom>=15] {
      line-join:round;
      #road { line-cap: round; }
      [zoom>=15] { line-width:2.5; line-color:#eee; }
      [zoom>=16] { line-width:4; }
    }
    [or_rdclass='private'][zoom>=15],[or_class='private'][zoom>=15] {
      line-join:round;
      #road { line-cap: round; }
      [zoom>=16] { line-width:2; line-color:#fff; }
    }
  }
}


// Labels


@name: '[name]';

// regular labels
#roads['mapnik::geometry_type'=2] {
  // Longer roads get a label earlier as they are likely to be more
  // important. This especially helps label density in rural/remote areas.
  // This z14 filter is *not* redundant to logic in SQL queries. Because z14
  // includes all data for z14+ via overzooming, the streets included in a
  // z14 vector tile include more features than ideal for optimal performance.
  [or_rdclass='national'][zoom>=12],[or_class='national'][zoom>=12],
  [or_rdclass='provincial'][zoom>=12],[or_class='provincial'][zoom>=12],
  [or_rdclass='municipal'][zoom<=14][len>2500],[or_class='municipal'][zoom<=14][len>2500],
  [or_rdclass='municipal'][zoom>=15],[or_class='municipal'][zoom>=15],
  [or_rdclass='barangay'],[or_class='barangay'] {
    text-avoid-edges: true;
    text-transform: uppercase;
    text-name: @name;
    text-character-spacing: 0.25;
    text-placement: line;
    text-face-name: @sans;
    text-fill: #444;
    text-size: 8;
    text-halo-fill: @road_halo;
    text-halo-radius: 1.5;
    text-halo-rasterizer: fast;
    text-min-distance: 200; // only for labels w/ the same name
    [zoom>=14] { text-size: 9; }
    [zoom>=16] { text-size: 11; }
    [zoom>=18] { text-size: 12; }
    [or_rdclass='national'],[or_class='national'],
    [or_rdclass='provincial'],[or_class='provincial'] {
      [zoom>=14] { text-size: 10; }
      [zoom>=16] { text-size: 11; text-face-name: @sans_bold; }
      [zoom>=17] { text-size: 12; }
      [zoom>=18] { text-size: 14; }
    }
  }
}